
一、上手
1.下载一个dnSpy;
链接
https://github.com/0xd4d/dnSpy/releases
2.打开dnSpy;
3.将目录
Steam\steamapps\common\Green Hell\GH_Data\Manage
下的全部文件拖到dnSpy左侧;
二、如何编辑一段代码
如图所示

三、常用代码以及部分说明
以我自己编辑的Mod举例子
例子格式:
类:XXXXXX
如何修改:XXXX
要点:XXXX
负重 InventoryBackpack.Awake
查找 InventoryBackpack.s_Instance = this;
下面添加 this.m_MaxWeight = 800f;
容器装汤 LiquidContainer.UpdateSlotsActivity
下面整段删除
else if (liquidContainerInfo.m_Amount > 0f && liquidContainerInfo.m_LiquidType != LiquidType.Water && liquidContainerInfo.m_LiquidType != LiquidType.UnsafeWater && liquidContainerInfo.m_LiquidType != LiquidType.DirtyWater)
{
this.m_GetSlot.gameObject.SetActive(false);
}
叠加倍率 ItemSlotStack.Awake
查找 this.m_StackDummies.Add(base.transform.GetChild(i).gameObject);
改成
for (int i = 0; i < base.transform.childCount; i++)
{
for (int j = 0; j < 2; j++)
{
this.m_StackDummies.Add(base.transform.GetChild(i).gameObject);
}
}
采收倍率 ItemInfo.LoadParams
查找 this.m_HarvestingResultItems.Add((ItemID)Enum.Parse(typeof(ItemID), array[i]));
改成
this.m_HarvestingResultItems.Add((ItemID)Enum.Parse(typeof(ItemID), array[i]));
this.m_HarvestingResultItems.Add((ItemID)Enum.Parse(typeof(ItemID), array[i]));
多复制一行就是增加一倍
冰箱 Food.Update
查找 float num = this.m_FInfo.m_SpoilOnlyIfTriggered ? this.m_FirstTriggerTime : this.m_FInfo.m_CreationTime;
在上方添加
if (base.m_InStorage && this.CanSpoil())
{
this.m_FInfo.m_CreationTime = (float)MainLevel.Instance.m_TODSky.Cycle.GameTime;
this.m_FirstTriggerTime = (float)MainLevel.Instance.m_TODSky.Cycle.GameTime;
return;
}
腐烂设定 FoodInfo.LoadParams
查找 this.m_SpoilTime = key.GetVariable(0).FValue结尾加上 *倍率 f ;
这段改成 if (key.GetName() == "SpoilTime")
{
this.m_SpoilTime = key.GetVariable(0).FValue * 2f;
return;
}
弓不晃动 BowController.StartShake
查找 Player.Get().StartShake(10f, 1f, 1f);
如果删除该行,则弓不会晃动
如果修改该行,则弓晃动可减少,比如
Player.Get().StartShake(1f, 1f, 1f);
武器工具无限耐久 HUDItemInHand.Update
查找 this.m_HPBar.fillAmount = this.m_Item.m_Info.m_Health / this.m_Item.m_Info.m_MaxHealth;
整段修改为
protected override void Update()
{
if (!this.m_Initialized)
{
return;
}
if (this.ShouldPerformSetup())
{
this.Setup();
}
this.UpdateStateVariables();
if (!this.m_Item)
{
if (SwimController.Get().IsActive() && SwimController.Get().m_AttachedHeavyObjects.Count > 0)
{
this.m_HPBar.fillAmount = (float)SwimController.Get().m_AttachedHeavyObjects.Count / (float)SwimController.Get().m_MaxNumHeavyObjectsToAttach;
}
else
{
this.m_HPBar.fillAmount = 1f;
}
}
else if (this.m_Item.m_Info.IsHeavyObject())
{
HeavyObject heavyObject = (HeavyObject)this.m_Item;
this.m_HPBar.fillAmount = (float)(heavyObject.m_Attached.Count + 1) / (float)(heavyObject.m_NumObjectsToAttach + 1);
}
else
{
if (this.m_Item.m_Info.IsWeapon() || this.m_Item.m_Info.IsTool())
{
this.m_Item.m_Info.m_Health = this.m_Item.m_Info.m_MaxHealth;
}
this.m_HPBar.fillAmount = this.m_Item.m_Info.m_Health / this.m_Item.m_Info.m_MaxHealth;
}
this.UpdateActions();
this.UpdateWeaponSwitchArrows();
}
}
护甲不坏 PlayerArmorModule.LateUpdate
查找 if (armorData.m_AttachedArmor.m_Info.m_Health <= 0f)
将 this.OnArmorDestroyed(armorData); 替换成下行
armorData.m_AttachedArmor.m_Info.m_Health = 1f;
护甲修理 PlayerArmorModule.OnRemoveItemFromSlot
查找 ArmorInfo armorInfo = (ArmorInfo)item.m_Info;下面添加
if (armorInfo.m_Health < armorInfo.m_MaxHealth * 0.5f)
{
armorInfo.m_Health = armorInfo.m_MaxHealth;
}
睡觉清空失眠 Insomnia.UpdateSleeping
整段改成
public void UpdateSleeping()
{
SleepController.Get().m_LastWakeUpTimeLogical += 20f * this.m_NoSleepTimeToIncreaseLevel;
}
背包显示物品缩小 Item.Initialize
查找 this.m_InventoryLocalScale = Vector3.one * this.m_Info.m_InventoryScale;
整段改成
public void Initialize(bool im_register)
{
if (this.m_Initialized)
{
return;
}
this.m_Initialized = true;
if (this.m_InventorySlot)
{
this.m_InventorySlot.m_Camera = Inventory3DManager.Get().m_Camera;
}
if (this.m_Info.m_Static && this.m_Info.m_ID != ItemID.Carcass)
{
this.ItemsManagerRegister(false);
this.m_DestroyingOnlyScript = true;
UnityEngine.Object.Destroy(this);
return;
}
if (Item.s_AllItemIDs.ContainsKey((int)this.m_Info.m_ID))
{
Item.s_AllItemIDs[(int)this.m_Info.m_ID] = Item.s_AllItemIDs[(int)this.m_Info.m_ID] + 1;
}
else
{
Item.s_AllItemIDs.Add((int)this.m_Info.m_ID, 1);
}
Item.s_AllItems.Add(this);
this.m_ScenarioItem = false;
if (base.gameObject.scene.IsValid() && GreenHellGame.Instance.m_ScenarioScenes.Contains(base.gameObject.scene.name))
{
this.m_ScenarioItem = true;
}
if (GreenHellGame.ROADSHOW_DEMO)
{
if (this.m_Info.m_BackpackPocket == BackpackPocket.Front || this.m_Info.m_BackpackPocket == BackpackPocket.Right)
{
this.m_Info.m_BackpackPocket = BackpackPocket.Main;
}
this.m_Info.m_Craftable = false;
}
if (this.m_Info.m_DestroyedPrefabName != string.Empty || this.m_Info.m_ItemsToBackpackOnDestroy.Count > 0 || base.gameObject.GetComponent<DestroyablePlant>())
{
if (this.m_Info.m_DestroyedIsFalling)
{
this.m_DestroyableObject = base.gameObject.AddComponent<DestroyableFallingObject>();
}
else
{
this.m_DestroyableObject = base.gameObject.AddComponent<DestroyableObject>();
}
this.m_DestroyableObject.m_Item = this;
}
if (this.m_Info.m_CanEquip || this.m_Info.IsHeavyObject())
{
DebugUtils.Assert(this.m_Holder != null, "Missing Holder in item " + this.m_InfoName, true, DebugUtils.AssertType.Info);
}
if (im_register)
{
this.ItemsManagerRegister(true);
}
this.m_DefaultLocalScale = base.transform.localScale;
this.m_InventoryLocalScale = Vector3.one * this.m_Info.m_InventoryScale * 0.7f;
if (this.m_Info.m_ID == ItemID.Tobacco_Leaf || this.m_Info.m_ID == ItemID.Molineria_leaf || this.m_Info.m_ID == ItemID.Plantain_lily_leaf || this.m_Info.m_ID == ItemID.Bone || this.m_Info.m_ID == ItemID.Cassava_bulb || this.m_Info.m_ID == ItemID.Malanga_bulb || this.m_Info.m_ID == ItemID.monstera_deliciosa_fruit || this.m_Info.m_ID == ItemID.Palm_heart)
{
this.m_InventoryLocalScale = Vector3.one * this.m_Info.m_InventoryScale * 0.5f;
}
if (this.m_Info.IsTool() || this.m_Info.IsWeapon() || this.m_Info.IsSeed())
{
this.m_InventoryLocalScale = Vector3.one * this.m_Info.m_InventoryScale;
}
if (this.m_BoxCollider)
{
this.m_DefaultSize = this.m_BoxCollider.size;
}
this.m_ThisRenderer = base.gameObject.GetComponent<Renderer>();
this.m_ChildrenRenderers = base.gameObject.GetComponentsInChildren<Renderer>(true);
this.m_DestroyableFallingObj = base.gameObject.GetComponent<DestroyableFallingObject>();
if (this.m_DestroyableFallingObj != null && this.m_AddAngularVelOnStart)
{
this.m_DestroyableFallingObj.AddAngularVelocityOnStart(this.m_AngularVelocityOnStart, this.m_AddAngularVelocityOnStartDuration);
}
}
}
生成物品 Player.UpdateInputs
private void UpdateInputs()
{
bool flag = this.m_PlayerControllers[28].IsActive();
bool flag2 = this.CanShowWatch();
if (flag && !flag2)
{
this.StopController(PlayerControllerType.Watch);
flag = false;
}
if (!GreenHellGame.Instance.m_Settings.m_ToggleWatch)
{
if (InputsManager.Get().IsActionActive(InputsManager.InputAction.Watch))
{
if (!flag && flag2)
{
this.StartController(PlayerControllerType.Watch);
return;
}
}
else if (flag)
{
this.StopController(PlayerControllerType.Watch);
}
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.Keypad8))
{
this.AddItemToInventory("QuestItem_Map_A");
this.AddItemToInventory("QuestItem_Map_B");
this.AddItemToInventory("QuestItem_Map_C");
this.AddItemToInventory("QuestItem_Map_A_Survi");
this.AddItemToInventory("QuestItem_Map_B_Survi");
this.AddItemToInventory("QuestItem_Map_C_Survi");
this.AddItemToInventory("QuestItem_Map_PVE");
this.AddItemToInventory("QuestItem_Map_PVE2");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.Keypad1))
{
this.AddItemToInventory("Molineria_leaf");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.Keypad2))
{
this.AddItemToInventory("Charcoal");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.Keypad3))
{
this.AddItemToInventory("Tobacco_Leaf");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.Keypad4))
{
this.AddItemToInventory("lily_flower");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.Keypad5))
{
this.AddItemToInventory("Quassia_Amara_flowers");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.Keypad6))
{
this.AddItemToInventory("coca_leafs");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.Keypad7))
{
this.AddItemToInventory("Painkillers");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.Keypad9))
{
this.AddItemToInventory("monstera_deliciosa_fruit");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.Keypad0))
{
this.AddItemToInventory("indigo_blue_leptonia");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.Alpha1))
{
this.AddItemToInventory("Beef_Jerky");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.Alpha2))
{
this.AddItemToInventory("Juice_Carton");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.Alpha3))
{
this.AddItemToInventory("Honeycomb");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.Alpha4))
{
this.AddItemToInventory("Tapir_Meat_Raw");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.Alpha5))
{
this.AddItemToInventory("Dry_leaf");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.Alpha6))
{
this.AddItemToInventory("Bird_Nest");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.Alpha7))
{
this.AddItemToInventory("Log");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.Alpha8))
{
this.AddItemToInventory("Bamboo_Log");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.Alpha9))
{
this.AddItemToInventory("Bamboo_Long_Stick");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.Alpha0))
{
this.AddItemToInventory("Rope");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.F1))
{
this.AddItemToInventory("metal_armor");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.F2))
{
this.AddItemToInventory("metal_blade");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.F3))
{
this.AddItemToInventory("metal_axe");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.F4))
{
this.AddItemToInventory("Metal_pickaxe");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.F5))
{
this.AddItemToInventory("Metal_arrow");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.F6))
{
this.AddItemToInventory("Obsidian_Stone");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.F7))
{
this.AddItemToInventory("Bone");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.F9))
{
this.AddItemToInventory("Bidon");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.F10))
{
this.AddItemToInventory("Pot");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.F11))
{
this.AddItemToInventory("Mud_Turtle_Meat_Raw");
}
if (Input.GetKey(KeyCode.RightControl) && Input.GetKeyDown(KeyCode.F12))
{
this.AddItemToInventory("safezone_totem");
}
}
}
泥沏滤水器过滤速度100倍+上层液体不减 MudWaterCollector.UpdateFiltering
整段改成
private void UpdateFiltering(float delta_time)
{
bool flag = false;
if (this.m_CollectorData.m_Amount > 0f && this.m_ContainerData.m_Amount < this.m_ContainerData.m_Capacity)
{
if (SleepController.Get().IsActive() && !SleepController.Get().IsWakingUp())
{
delta_time = Player.GetSleepTimeFactor();
}
float num = delta_time * 50f;
if (num > this.m_CollectorData.m_Amount)
{
num = this.m_CollectorData.m_Amount;
}
this.m_ContainerData.m_Amount += num;
flag = true;
}
if (this.m_Particle.activeSelf != flag)
{
this.m_Particle.SetActive(flag);
}
base.ReplSetDirty();
}
}
死亡只掉落手中的道具 DeathController.Respawn
查找并删除 this.DropInventory();
多人联机数 P2PSession
查找 P2PSession.MAX_PLAYERS = 4;
将4修改为你需要的数值
随处建造 ConstructionGhost.UpdateProhibitionType
整段修改为
public void UpdateProhibitionType(bool check_is_snapped = true)
{
if (this.m_AdditionalPlacingConditions.Contains(ConstructionGhost.GhostPlacingCondition.IsSnapped) && !this.m_ConstructionToAttachTo && EnumTools.IsItemToAttachToTree(this.m_ResultItemID) && this.m_SelectedSlot != null)
{
if (this.m_SelectedSlot.m_Construction != null)
{
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
Vector3 center = this.m_BoxCollider.bounds.center;
Vector3 vector = this.m_BoxCollider.size * 0.5f;
center.y += this.m_ColliderShrinkBottom * 0.5f;
vector.y -= this.m_ColliderShrinkBottom;
vector.y = Mathf.Max(vector.y, 0f);
int num = Physics.OverlapBoxNonAlloc(center, vector, ConstructionGhost.s_CollidersTemp, this.m_BoxCollider.transform.rotation);
for (int i = 0; i < num; i++)
{
Collider collider = ConstructionGhost.s_CollidersTemp[i];
ConstructionGhost constructionGhost = collider.gameObject.GetComponent<ConstructionGhost>();
if (!constructionGhost && collider.gameObject.transform.parent)
{
constructionGhost = collider.gameObject.GetComponentInParent<ConstructionGhost>();
}
if (constructionGhost && constructionGhost != this && constructionGhost.m_ResultItemID == this.m_ResultItemID)
{
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
}
return;
}
else
{
if (this.GetConstructForbidden() == ConstructionGhost.ConstructForbidden.Forbidden)
{
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
if (this.m_UseExpandedBoundsTocheckRegrowingTrees)
{
this.UpdateExpandedBounds();
}
if (this.AreExtendedBoundsCollidingWithTrunk() || this.AreExtendedBoundsCollidingWithRegrowingTree())
{
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
if (!this.m_CanBePlacedOnTopOfConstruction && this.m_OnTopOfConstruction)
{
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
if (check_is_snapped && this.m_AdditionalPlacingConditions.Contains(ConstructionGhost.GhostPlacingCondition.IsSnapped) && !this.m_ConstructionToAttachTo)
{
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
if (this.m_SelectedSlot)
{
foreach (ConstructionSlot constructionSlot in this.m_SelectedSlot.gameObject.GetComponents<ConstructionSlot>())
{
if (constructionSlot.m_Construction && constructionSlot.m_Construction.gameObject.activeSelf && (!constructionSlot.m_Construction.m_Info.IsWall() || this.m_ResultInfo.IsWall()) && (constructionSlot.m_Construction.m_Info.IsWall() || !this.m_ResultInfo.IsWall()))
{
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
}
}
if (ItemInfo.IsStoneRing(this.m_ResultItemID) && this.m_Firecamp && this.m_Firecamp.m_StoneRing)
{
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
if (this.m_Corners != null)
{
foreach (BoxCollider boxCollider in this.m_Corners)
{
bool enabled = boxCollider.enabled;
boxCollider.enabled = true;
bool flag = this.IsInAir(boxCollider.bounds.center, boxCollider.bounds.min);
boxCollider.enabled = enabled;
if (flag)
{
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
}
}
if (this.IsOnUpperLevel() && this.m_UpperLevelCorners != null)
{
foreach (BoxCollider boxCollider2 in this.m_UpperLevelCorners)
{
bool enabled2 = boxCollider2.enabled;
boxCollider2.enabled = true;
Vector3 center2 = boxCollider2.bounds.center;
center2.y += boxCollider2.bounds.max.y;
bool flag2 = this.IsCornerInAir(center2, boxCollider2.bounds.min);
boxCollider2.enabled = enabled2;
if (flag2)
{
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
}
}
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
if (this.m_AllignToTerrain && !this.m_Smoker && this.m_FirecampRacks.Count == 0 && Vector3.Angle(base.transform.up, Vector3.up) > this.m_MaxAllignAngle)
{
this.ClearCollidingPlants();
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
Vector3 center3 = this.m_BoxCollider.bounds.center;
Vector3 vector2 = this.m_BoxCollider.size * 0.5f;
center3.y += this.m_ColliderShrinkBottom * 0.5f;
vector2.y -= this.m_ColliderShrinkBottom;
vector2.y = Mathf.Max(vector2.y, 0f);
this.m_Colliders.Clear();
if (this.m_TestColliders != null)
{
foreach (BoxCollider boxCollider3 in this.m_TestColliders)
{
Vector3 size = boxCollider3.size;
size.x *= boxCollider3.transform.localScale.x;
size.y *= boxCollider3.transform.localScale.y;
size.z *= boxCollider3.transform.localScale.z;
int num2 = Physics.OverlapBoxNonAlloc(boxCollider3.bounds.center, size * 0.5f, ConstructionGhost.s_CollidersTemp, boxCollider3.transform.rotation);
for (int k = 0; k < num2; k++)
{
Collider collider2 = ConstructionGhost.s_CollidersTemp[k];
if (!this.m_Colliders.Contains(collider2) && !this.m_TestColliders.Contains(collider2))
{
if (this.m_ResultItemID != ItemID.TroughFood && this.m_ResultItemID != ItemID.TroughWater && collider2.gameObject.GetComponent<Farm>())
{
this.ClearCollidingPlants();
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
if (collider2.isTrigger && !collider2.gameObject.GetComponent<ConstructionGhost>())
{
Spikes component = collider2.gameObject.GetComponent<Spikes>();
Acre exists = collider2.gameObject.transform.parent ? collider2.gameObject.transform.parent.GetComponent<Acre>() : null;
FramePlacingObstacle component2 = collider2.gameObject.GetComponent<FramePlacingObstacle>();
ConstructBlockSensor component3 = collider2.gameObject.GetComponent<ConstructBlockSensor>();
if (component3)
{
if (this.ShouldIgnoreConstructionBlocker(component3))
{
goto IL_6DF;
}
this.TryToShowRestrictedAreaHint();
}
if (!component && !exists && !component2 && !component3)
{
goto IL_6DF;
}
}
if (!(collider2.gameObject == Terrain.activeTerrain.gameObject) && !(collider2.transform.parent == base.transform))
{
this.m_Colliders.Add(collider2);
}
}
IL_6DF:;
}
}
}
else
{
int num3 = Physics.OverlapBoxNonAlloc(center3, vector2, ConstructionGhost.s_CollidersTemp, this.m_BoxCollider.transform.rotation);
this.m_Colliders.Resize(num3);
for (int l = 0; l < num3; l++)
{
this.m_Colliders[l] = ConstructionGhost.s_CollidersTemp[l];
}
}
this.m_Colliders.Remove(Player.Get().m_Collider);
this.m_Colliders.Remove(this.m_BoxCollider);
if (this.m_AdditionalPlacingConditions.Contains(ConstructionGhost.GhostPlacingCondition.NeedFirecamp) && this.m_Firecamp)
{
this.m_Colliders.Remove(this.m_Firecamp.m_Collider);
if (this.m_Firecamp.m_StoneRing)
{
this.m_Colliders.Remove(this.m_Firecamp.m_StoneRing.m_Collider);
}
}
if ((ItemInfo.IsFirecamp(this.m_ResultItemID) || ItemInfo.IsStoneRing(this.m_ResultItemID)) && this.m_FirecampRacks.Count > 0)
{
foreach (FirecampRack firecampRack in this.m_FirecampRacks)
{
this.m_Colliders.Remove(firecampRack.m_Collider);
}
}
if ((ItemInfo.IsFirecamp(this.m_ResultItemID) || ItemInfo.IsStoneRing(this.m_ResultItemID)) && this.m_Smoker)
{
this.m_Colliders.Remove(this.m_Smoker.m_Collider);
}
if (ConstructionChainController.Get().IsActive())
{
foreach (ConstructionGhostChain constructionGhostChain in ConstructionChainController.Get().m_Chain)
{
this.m_Colliders.Remove(constructionGhostChain.m_Collider);
}
}
if (this.m_ResultItemID == ItemID.TroughFood || this.m_ResultItemID == ItemID.TroughWater)
{
bool flag3 = false;
using (List<Collider>.Enumerator enumerator4 = this.m_Colliders.GetEnumerator())
{
while (enumerator4.MoveNext())
{
if (enumerator4.Current.gameObject.GetComponent<Farm>() != null)
{
flag3 = true;
break;
}
}
}
if (!flag3)
{
this.ClearCollidingPlants();
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
}
if (this.m_ResultItemID != ItemID.Stick_Fish_Trap && this.m_ResultItemID != ItemID.Big_Stick_Fish_Trap)
{
foreach (Collider collider3 in this.m_Colliders)
{
Item component4 = collider3.gameObject.GetComponent<Item>();
if (!(component4 != null) || component4.m_Info == null || component4.m_Info.IsConstruction() || component4.m_IsPlant || component4.m_IsTree)
{
Farm component5 = collider3.gameObject.GetComponent<Farm>();
if (component5)
{
if (this.m_ResultItemID != ItemID.TroughFood && this.m_ResultItemID != ItemID.TroughWater)
{
this.ClearCollidingPlants();
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
if ((this.m_ResultItemID == ItemID.TroughFood || this.m_ResultItemID == ItemID.TroughWater) && this.m_Colliders.Contains(component5.m_DoorArea))
{
this.ClearCollidingPlants();
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
}
if (collider3.isTrigger)
{
if ((this.m_ResultItemID == ItemID.building_frame || this.m_ResultItemID == ItemID.building_bamboo_frame || this.m_ResultItemID == ItemID.wooden_frame_triangle || this.m_ResultItemID == ItemID.bamboo_frame_triangle) && collider3.gameObject.GetComponent<FramePlacingObstacle>())
{
this.ClearCollidingPlants();
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
UnityEngine.Object component6 = collider3.gameObject.GetComponent<Spikes>();
Acre exists2 = collider3.gameObject.transform.parent ? collider3.gameObject.transform.parent.GetComponent<Acre>() : null;
ConstructBlockSensor component7 = collider3.gameObject.GetComponent<ConstructBlockSensor>();
if (component6 || exists2 || component7)
{
if (component7)
{
if (this.ShouldIgnoreConstructionBlocker(component7))
{
continue;
}
this.TryToShowRestrictedAreaHint();
}
this.ClearCollidingPlants();
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
ConstructionGhost component8 = collider3.gameObject.GetComponent<ConstructionGhost>();
if (!(component8 != null))
{
continue;
}
if (component8.m_ResultItemID == ItemID.mud_mixer)
{
this.ClearCollidingPlants();
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
using (List<GhostStep>.Enumerator enumerator6 = component8.m_Steps.GetEnumerator())
{
while (enumerator6.MoveNext())
{
GhostStep ghostStep = enumerator6.Current;
foreach (GhostSlot ghostSlot in ghostStep.m_Slots)
{
if (base.m_Collider.bounds.Intersects(ghostSlot.m_Collider.bounds))
{
this.ClearCollidingPlants();
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
}
}
continue;
}
}
if (!this.m_ConstructionToAttachTo || (!(collider3.gameObject == this.m_ConstructionToAttachTo.gameObject) && !(collider3.gameObject == Terrain.activeTerrain.gameObject)))
{
ConstructionGhost component9 = collider3.gameObject.GetComponent<ConstructionGhost>();
if (component9 != null)
{
foreach (GhostStep ghostStep2 in component9.m_Steps)
{
foreach (GhostSlot ghostSlot2 in ghostStep2.m_Slots)
{
if (base.m_Collider.bounds.Intersects(ghostSlot2.m_Collider.bounds))
{
this.ClearCollidingPlants();
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
}
}
}
Construction construction = collider3.gameObject.GetComponent<Construction>();
if (!construction && collider3.gameObject.transform.parent)
{
construction = collider3.gameObject.GetComponentInParent<Construction>();
}
if (construction)
{
if (!(construction == this.m_ConstructionToAttachTo) && (this.IsBalcony(this.m_ResultItemID) || this.IsFrameTriangle(this.m_ResultItemID) || this.IsFrameTriangle(construction.GetInfoID()) || (this.m_ConstructionToAttachTo && this.IsFrameTriangle(this.m_ConstructionToAttachTo.GetInfoID())) || !this.m_ConstructionToAttachTo || !this.m_ConstructionToAttachTo.IsConstructionConnected(construction)))
{
if (ConstructionChainController.Get().IsActive())
{
if (ConstructionChainController.Get().IsStartOrEnd(construction))
{
continue;
}
if (construction.m_Info.IsWall())
{
this.ClearCollidingPlants();
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
bool flag4 = false;
for (int m = 0; m < 2; m++)
{
Construction construction2 = (m == 0) ? ConstructionChainController.Get().GetStartConstructionToAttachTo() : ConstructionChainController.Get().GetEndConstructionToAttachTo();
if (construction2 && !this.IsBalcony(this.m_ResultItemID) && !this.IsFrameTriangle(this.m_ResultItemID) && !this.IsFrameTriangle(construction.GetInfoID()) && (!this.m_ConstructionToAttachTo || !this.IsFrameTriangle(construction2.GetInfoID())) && construction2 && construction2.IsConstructionConnected(construction))
{
flag4 = true;
break;
}
}
if (flag4)
{
continue;
}
}
if (this.m_SelectedSlot && this.m_SelectedSlot.m_ParentConstruction)
{
int num4 = this.m_SelectedSlot.m_UpperLevelSlot ? (this.m_SelectedSlot.m_ParentConstruction.m_Level + 1) : this.m_SelectedSlot.m_ParentConstruction.m_Level;
if (construction.m_Level != num4)
{
continue;
}
}
if ((!this.IsOnUpperLevel() || construction.m_Level != 0) && (this.IsOnUpperLevel() || construction.m_Level <= 0))
{
this.ClearCollidingPlants();
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
}
}
else
{
ConstructionGhost exists3 = null;
if (collider3.transform.parent)
{
exists3 = collider3.transform.parent.GetComponent<ConstructionGhost>();
}
if (!collider3.gameObject.IsWater() && !this.m_LayerMasksToIgnore.Contains(collider3.gameObject.layer) && !collider3.isTrigger && !exists3 && !this.HackForTreePlatformFloor(collider3))
{
this.ClearCollidingPlants();
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
}
}
}
}
}
if (this.m_ResultItemID == ItemID.farm)
{
center3 = this.m_BoxCollider.bounds.center;
vector2 = this.m_BoxCollider.size * 0.5f;
vector2.y = Mathf.Max(vector2.y, 0f);
int num5 = Physics.OverlapBoxNonAlloc(center3, vector2, ConstructionGhost.s_CollidersTemp, this.m_BoxCollider.transform.rotation);
this.m_Colliders.Resize(num5);
for (int n = 0; n < num5; n++)
{
this.m_Colliders[n] = ConstructionGhost.s_CollidersTemp[n];
}
this.m_Colliders.Remove(Player.Get().m_Collider);
this.m_Colliders.Remove(this.m_BoxCollider);
}
Collider collider4 = null;
foreach (Collider collider5 in this.m_Colliders)
{
if (collider5.gameObject.IsWater())
{
collider4 = collider5;
break;
}
}
if (this.m_AdditionalPlacingConditions.Contains(ConstructionGhost.GhostPlacingCondition.MustBeInWater) && !collider4)
{
if (this.m_Hook)
{
center3 = this.m_Hook.bounds.center;
vector2 = this.m_Hook.size * 0.5f;
int num6 = Physics.OverlapBoxNonAlloc(center3, vector2, ConstructionGhost.s_CollidersTemp, this.m_Hook.transform.rotation);
for (int num7 = 0; num7 < num6; num7++)
{
if (ConstructionGhost.s_CollidersTemp[num7].gameObject.IsWater())
{
return;
}
}
}
this.ClearCollidingPlants();
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
if (this.m_AdditionalPlacingConditions.Contains(ConstructionGhost.GhostPlacingCondition.MustBeInWater) && collider4 && this.m_Hook)
{
this.ClearCollidingPlants();
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
if ((this.m_AdditionalPlacingConditions.Contains(ConstructionGhost.GhostPlacingCondition.CantBeInWater) || this.m_AdditionalPlacingConditions.Contains(ConstructionGhost.GhostPlacingCondition.NeedFirecamp)) && collider4)
{
this.ClearCollidingPlants();
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
if (collider4 && this.m_MaxDepthOfWater > 0f && collider4.bounds.max.y - this.m_BoxCollider.bounds.min.y > this.m_MaxDepthOfWater)
{
this.ClearCollidingPlants();
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
if (this.m_AdditionalPlacingConditions.Contains(ConstructionGhost.GhostPlacingCondition.Whatever) || this.m_AdditionalPlacingConditions.Contains(ConstructionGhost.GhostPlacingCondition.CantBeInWater) || this.m_ResultItemID == ItemID.bamboo_platform || this.m_ResultItemID == ItemID.bamboo_platform_triangle)
{
List<GameObject> list = new List<GameObject>();
foreach (Collider collider6 in this.m_Colliders)
{
if (this.m_LayerMasksToIgnore.Contains(collider6.gameObject.layer) && collider6.gameObject.layer != this.m_ItemLayer)
{
if (!this.m_CollidingPlants.ContainsKey(collider6.gameObject))
{
this.AddCollidingPlant(collider6.gameObject);
}
list.Add(collider6.gameObject);
}
}
int num8 = 0;
while (num8 < this.m_CollidingPlants.Keys.Count)
{
if (!list.Contains(this.m_CollidingPlants.ElementAt(num8).Key))
{
this.RemoveCollidingPlant(this.m_CollidingPlants.ElementAt(num8).Key);
}
else
{
num8++;
}
}
}
if (this.m_ConstructionBelow && this.m_ConstructionBelow.m_Level >= 3)
{
this.ClearCollidingPlants();
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
if (this.m_CollidingPlants.Count > 0)
{
this.m_ProhibitionType = ConstructionGhost.ProhibitionType.None;
return;
}
return;
}
}
}
F8一键完成蓝图 ConstructionGhost.UpdateState
整段修改为
public virtual void UpdateState()
{
if (this.IsReady() || Input.GetKeyDown(KeyCode.F8))
{
this.SetState(ConstructionGhost.GhostState.Ready);
}
ConstructionGhost.GhostState state = this.m_State;
if (state == ConstructionGhost.GhostState.Dragging)
{
this.UpdateRotation();
this.UpdateTransform();
this.UpdateColor();
this.UpdateShaderProps();
return;
}
if (state != ConstructionGhost.GhostState.Building)
{
return;
}
this.UpdateShaderProps();
if (this.ReplIsOwner() && this.IsReady())
{
this.SetState(ConstructionGhost.GhostState.Ready);
}
}
}
无敌模式 MainLevel.UpdateInputsDebug
整段改成

private void UpdateInputsDebug()
{
if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.G))
{
Cheats.m_GodMode = !Cheats.m_GodMode;
return;
}
功能
左Ctrl+G开启无敌模式
无限视距 UpdateSizeAndOpacity

建筑大师 Construction.TakeDamage
第一步 定义 m_NoSpawn
搜索类 Cheats.
添加 public static bool m_NoSpawn;

第二步 添加按键,开启 m_NoSpawn
搜索类 MainLevel.UpdateInputsDebug
在原文段之后添加代码
else if (Input.GetKeyUp(KeyCode.H))
{
Cheats.m_NoSpawn = !Cheats.m_NoSpawn;
}
整段变成
private void UpdateInputsDebug()
{
if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.G))
{
Cheats.m_GodMode = !Cheats.m_GodMode;
return;
}
if (Input.GetKeyDown(KeyCode.KeypadPeriod))
{
this.m_TODTime.ProgressTime = !this.m_TODTime.ProgressTime;
}
else if (Input.GetKeyUp(KeyCode.H))
{
Cheats.m_NoSpawn = !Cheats.m_NoSpawn;
}
}
}
说明
左Ctrl+G开启无敌模式
左Ctrl+H开启 建筑大师m_NoSpawn
小键盘.冻结时间
第三步 设置摧毁效果
搜索类 Construction.TakeDamage
CTRL+F搜索if (this.m_CurrentHitsCount >= this.m_ConstructionInfo.m_HitsCountToDestroy)将上面代码及其以后整个替换成
if (this.m_CurrentHitsCount > (Cheats.m_GodMode ? 1 : this.m_ConstructionInfo.m_HitsCountToDestroy) || Cheats.m_GodMode)
{
if (Cheats.m_NoSpawn)
{
UnityEngine.Object.Destroy(base.gameObject);
}
else
{
this.DestroyMe(true, false, true, true);
}
}
else
{
this.m_LastDamageTime = Time.time;
base.HitShake();
}
return true;
}
}

说明
开启无敌模式和m_NoSpawn时,玩家可以一击拆除建筑,且不掉材料。
第四步 设置文字提醒显示
搜索类 MainLevel.UpdateInputsDebug
整段改成
if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.G))
{
Cheats.m_GodMode = !Cheats.m_GodMode;
string str = "无敌模式\u00a0-\u00a0";
if (Cheats.m_GodMode)
{
HUDMessages.Get().AddMessage(str + "已开启", new Color?(new Color(21f, 228f, 142f, 1f)), HUDMessageIcon.None, "", null);
return;
}
HUDMessages.Get().AddMessage(str + "已关闭", new Color?(new Color(224f, 66f, 54f, 1f)), HUDMessageIcon.None, "", null);
return;
}
else if (Input.GetKeyDown(KeyCode.KeypadPeriod))
{
this.m_TODTime.ProgressTime = !this.m_TODTime.ProgressTime;
string str2 = "时间冻结\u00a0-\u00a0";
if (this.m_TODTime.ProgressTime)
{
HUDMessages.Get().AddMessage(str2 + "已关闭", new Color?(new Color(21f, 228f, 142f, 1f)), HUDMessageIcon.None, "", null);
return;
}
HUDMessages.Get().AddMessage(str2 + "已开启", new Color?(new Color(224f, 66f, 54f, 1f)), HUDMessageIcon.None, "", null);
return;
}
else
{
if (Input.GetKeyDown(KeyCode.Keypad9))
{
SaveGame.Save();
return;
}
if (!Input.GetKeyUp(KeyCode.H))
{
return;
}
Cheats.m_NoSpawn = !Cheats.m_NoSpawn;
string str3 = "建筑大师\u00a0-\u00a0";
if (Cheats.m_NoSpawn)
{
HUDMessages.Get().AddMessage(str3 + "已开启", new Color?(new Color(21f, 228f, 142f, 1f)), HUDMessageIcon.None, "", null);
return;
}
HUDMessages.Get().AddMessage(str3 + "已关闭", new Color?(new Color(224f, 66f, 54f, 1f)), HUDMessageIcon.None, "", null);
return;
}
}
}
说明
增加了一个保存的功能
debugmod主要功能
★F1刷物品F3传送F4加技能点F5刷敌对AI F6调整状态 ctrl+U开启所有建筑蓝图
搜索ItemsManager.UpdateDebug
private void UpdateDebug()下面替换成下面代码
{
if (Input.GetKeyDown(KeyCode.F1))
{
MenuInGameManager.Get().ShowScreen(typeof(MenuDebugItem));
return;
}
if (Input.GetKeyDown(KeyCode.F3))
{
MenuInGameManager.Get().ShowScreen(typeof(MenuDebugSpawners));
return;
}
if (Input.GetKeyDown(KeyCode.F4))
{
MenuInGameManager.Get().ShowScreen(typeof(MenuDebugSkills));
return;
}
if (Input.GetKeyDown(KeyCode.F5))
{
MenuInGameManager.Get().ShowScreen(typeof(MenuDebugAI));
return;
}
if (Input.GetKeyDown(KeyCode.F6))
{
MenuInGameManager.Get().ShowScreen(typeof(MenuDebugWounds));
return;
}
if (this.m_DebugSpawnID != ItemID.None && Input.GetKeyDown(KeyCode.F2))
{
Localization localization = GreenHellGame.Instance.GetLocalization();
Vector3 forward = Player.Get().GetHeadTransform().forward;
Vector3 vector = Player.Get().GetHeadTransform().position + 0.5f * forward;
RaycastHit raycastHit;
vector = (Physics.Raycast(vector, forward, out raycastHit, 3f) ? raycastHit.point : (vector + forward * 2f));
this.CreateItem(this.m_DebugSpawnID, true, vector - forward * 0.2f, Player.Get().transform.rotation, false);
string text = localization.Get(this.m_DebugSpawnID.ToString(), true);
text = ((text.IndexOf("MISSING TEXT") == -1) ? text : this.m_DebugSpawnID.ToString());
HUDMessages.Get().AddMessage(string.Format("物品【{0}】创建成功", text), new Color?(new Color(224f, 66f, 54f, 1f)), HUDMessageIcon.None, "", null);
}
if (Input.GetKeyDown(KeyCode.P))
{
this.UnlockItemInNotepad(ItemID.Logs_Bed);
}
if (Input.GetKey(KeyCode.U) && Input.GetKey(KeyCode.LeftControl))
{
this.UnlockAllItemsInNotepad();
PlayerDiseasesModule.Get().UnlockAllDiseasesInNotepad();
PlayerDiseasesModule.Get().UnlockAllDiseasesTratmentInNotepad();
PlayerDiseasesModule.Get().UnlockAllSymptomsInNotepad();
PlayerDiseasesModule.Get().UnlockAllSymptomTreatmentsInNotepad();
PlayerInjuryModule.Get().UnlockAllInjuryState();
PlayerInjuryModule.Get().UnlockAllInjuryStateTreatment();
PlayerInjuryModule.Get().UnlockAllKnownInjuries();
this.UnloackAllConsumed();
this.UnlockAllCrafted();
this.UnlockAllBoiledData();
this.UnlockAllCollected();
this.UnlockAllItemInfos();
MapTab mapTab = (MapTab)MenuNotepad.Get().m_Tabs[MenuNotepad.MenuNotepadTab.MapTab];
if (mapTab == null)
{
return;
}
mapTab.UnlockAll(true);
}
}
}
“保存并退出”按钮改随处保存
第一步 更改按钮定义
搜索类 m_SaveAndQuitButton
修改为 m_SaveButton
搜索类 SaveAndQuit
修改为 Save
第二步 更改按钮描述
搜索类 MenuInGame
找到 MenuInGame_SaveAndQuit
改为 MenuInGame_Save

此时游戏内“保存并退出”按钮变更为“保存游戏”
第三步 删除对话
搜索类 OnSaveAndQuit
中间直接改成
{
SaveGame.Save();
return;
}
此时点击游戏内“保存游戏”,不再需要确认,而是直接保存游戏。
第四步 功能实现
搜索类 UpdateSaveAndQuit
删除 this.ReturnToMainMenu();
此时点击游戏内“保存游戏”,不再跳到主菜单。
四、关于部分功能的说明
1.随处建造本身就包含了解除限高,因此不要纠结为什么这里面没有解除限高。类似问题还有很多,其实这都不是问题。
2.“冰箱”的意思是放进去的食物、花朵不会腐败。如果你需要干燥的花朵来进行种植,就别放冰箱了。
3.图标修改会导致长按y自动整理背包时,部分图标溢出背包界面。这时候可以点击相关页面的图标,重置图标错误。举例来说,比如我使用自动整理背包,整理烟草业、船子草、羽毛……这个原料界面,出现错误的时候,我只需要点一下背包页面那五个的中间那个图标就可以了。
4.F8一键生成并不是立即生成instantly build,立即生成是指拉完蓝图以后立即生成。考虑到配合随处建造,立即生成可能会造成一些问题。包括,但不限于泥巴平台拉到水面以下导致河床一堆“粑粑”异常难看、火堆卡贴图去不掉、多重建筑等等问题。
其实立即生成instantly build还会包含一个范围问题。网上的建议是直接删了,这样会导致一些问题,比如亚马逊之魂第三章需要修复图腾。如果你直接删除了Range()的范围限制,那么你刚进亚马逊之魂才开始第一章的时候,第三章的图腾可能已经完成了,但由于你没有开第三章的图,没有和第三章哈巴库长老对话,从而失去第三章重建图腾的信任度,这样会导致第三章剧情比较难进行。另外就是如果有玩家在房间开挂,同样会导致这个问题产生。
5.正常情况下,“多人房”一般不和“无限视距”一起用,因为多人房超过4个人时,必定是多出来的那些玩家在游戏中都没有名字。至于是不是具有无限视距,对房间里的人来说没有任何意义。因为当你使用“多人房”mod时,原本的这4名玩家也可能失去名字,不被其他人看到,或者看不到别人的名字。房间前4名玩家出现这个bug的时候,玩家原地睡觉并且立即醒来可能会取消这个bug效果。
6.无敌以及以上代码全部经过多个版本测试并无bug。如果你的代码不能运行,只能是你的输入有错误。你可以尝试在群里询问其他mod制作者,记得配上你的截图代码段,以便寻找错误。
五、最后
感谢您能看到最后。如果还有什么问题,可以来群里讨论。最后祝您中秋快乐!阖家团圆。
我们的讨论群:
绿色地狱一群:751219981
绿色地狱二群:211609466
绿色地狱三群:557062795