public GameObject DoPlacement(Construction.Target placement, Construction component) { BasePlayer ownerPlayer = base.GetOwnerPlayer(); if (!ownerPlayer) { return(null); } BaseEntity baseEntity = component.CreateConstruction(placement, true); if (!baseEntity) { return(null); } float single = 1f; float single1 = 0f; Item ownerItem = base.GetOwnerItem(); if (ownerItem != null) { baseEntity.skinID = ownerItem.skin; if (ownerItem.hasCondition) { single = ownerItem.conditionNormalized; } } baseEntity.gameObject.AwakeFromInstantiate(); BuildingBlock buildingBlock = baseEntity as BuildingBlock; if (buildingBlock) { buildingBlock.blockDefinition = PrefabAttribute.server.Find <Construction>(buildingBlock.prefabID); if (!buildingBlock.blockDefinition) { Debug.LogError("Placing a building block that has no block definition!"); return(null); } buildingBlock.SetGrade(buildingBlock.blockDefinition.defaultGrade.gradeBase.type); single1 = buildingBlock.currentGrade.maxHealth; } BaseCombatEntity baseCombatEntity = baseEntity as BaseCombatEntity; if (baseCombatEntity) { single1 = (buildingBlock != null ? buildingBlock.currentGrade.maxHealth : baseCombatEntity.startHealth); baseCombatEntity.ResetLifeStateOnSpawn = false; baseCombatEntity.InitializeHealth(single1 * single, single1); } baseEntity.gameObject.SendMessage("SetDeployedBy", ownerPlayer, SendMessageOptions.DontRequireReceiver); baseEntity.OwnerID = ownerPlayer.userID; baseEntity.Spawn(); if (buildingBlock) { Effect.server.Run("assets/bundled/prefabs/fx/build/frame_place.prefab", baseEntity, 0, Vector3.zero, Vector3.zero, null, false); } StabilityEntity stabilityEntity = baseEntity as StabilityEntity; if (stabilityEntity) { stabilityEntity.UpdateSurroundingEntities(); } return(baseEntity.gameObject); }
public GameObject DoPlacement(Construction.Target placement, Construction component) { BasePlayer ownerPlayer = this.GetOwnerPlayer(); if (!Object.op_Implicit((Object)ownerPlayer)) { return((GameObject)null); } BaseEntity construction = component.CreateConstruction(placement, true); if (!Object.op_Implicit((Object)construction)) { return((GameObject)null); } float num1 = 1f; float num2 = 0.0f; Item ownerItem = this.GetOwnerItem(); if (ownerItem != null) { construction.skinID = ownerItem.skin; if (ownerItem.hasCondition) { num1 = ownerItem.conditionNormalized; } } ((Component)construction).get_gameObject().AwakeFromInstantiate(); BuildingBlock buildingBlock = construction as BuildingBlock; if (Object.op_Implicit((Object)buildingBlock)) { buildingBlock.blockDefinition = PrefabAttribute.server.Find <Construction>(buildingBlock.prefabID); if (!(bool)((PrefabAttribute)buildingBlock.blockDefinition)) { Debug.LogError((object)"Placing a building block that has no block definition!"); return((GameObject)null); } buildingBlock.SetGrade(buildingBlock.blockDefinition.defaultGrade.gradeBase.type); num2 = buildingBlock.currentGrade.maxHealth; } BaseCombatEntity baseCombatEntity = construction as BaseCombatEntity; if (Object.op_Implicit((Object)baseCombatEntity)) { float newmax = Object.op_Inequality((Object)buildingBlock, (Object)null) ? buildingBlock.currentGrade.maxHealth : baseCombatEntity.startHealth; baseCombatEntity.ResetLifeStateOnSpawn = false; baseCombatEntity.InitializeHealth(newmax * num1, newmax); } ((Component)construction).get_gameObject().SendMessage("SetDeployedBy", (object)ownerPlayer, (SendMessageOptions)1); construction.OwnerID = ownerPlayer.userID; construction.Spawn(); if (Object.op_Implicit((Object)buildingBlock)) { Effect.server.Run("assets/bundled/prefabs/fx/build/frame_place.prefab", construction, 0U, Vector3.get_zero(), Vector3.get_zero(), (Connection)null, false); } StabilityEntity stabilityEntity = construction as StabilityEntity; if (Object.op_Implicit((Object)stabilityEntity)) { stabilityEntity.UpdateSurroundingEntities(); } return(((Component)construction).get_gameObject()); }