상속: CountedInstance
예제 #1
0
        // BuildingBlock.DoBuild()
        public static void EntityBuildingUpdate(BuildingBlock bb, HitInfo info)
        {
            // hammer prof = 1
            // works
            // called anytime you hit a building block with a constructor item (hammer)
            BasePlayer player      = info.Initiator as BasePlayer;
            float      proficiency = info.resourceGatherProficiency;

            var bp  = new BuildingPart(bb);
            var p   = new Player(player);
            var ebe = new Events.BuildingEvent(bp, p, proficiency);

            OnBuildingUpdate.OnNext(ebe);
        }
        public void On_Placement(BuildingEvent be)
        {
            if (StructureRecorder)
            {
                Player player = be.Builder;
                string name;
                if (DataStore.ContainsKey("StructureRecorder", player.SteamID))
                {
                    name = (string)DataStore.Get("StructureRecorder", player.SteamID);
                }
                else if (DataStore.ContainsKey("StructureRecorderEveryone", "ON"))
                {
                    name = (string)DataStore.Get("StructureRecorderEveryone", "ON");
                }
                else
                {
                    return;
                }
                BuildingPart bp = be.BuildingPart;
                Structure structure;
                Structures.TryGetValue(name, out structure);
                if (structure == null)
                {
                    return;
                }

                structure.AddComponent(bp);
                player.Message("Added " + bp.Name);
            }
        }
예제 #3
0
파일: Hooks.cs 프로젝트: Viproz/Pluton
        // Construiction.Common.CreateConstruction()
        public static BaseEntity DoPlacement(Construction construction, Construction.Target target, bool bNeedsValidPlacement)
        {
            try {
                GameObject gameObject = GameManager.server.CreatePrefab(construction.fullName, default(Vector3), default(Quaternion), true);
                BuildingBlock component = gameObject.GetComponent<BuildingBlock>();

                bool flag = construction.UpdatePlacement(gameObject.transform, construction, target);
                if (bNeedsValidPlacement && !flag) {
                    UnityEngine.Object.Destroy(gameObject);
                    return null;
                }

                BuildingEvent be = null;
                if (component != null) {
                    be = new BuildingEvent(construction, target, component, bNeedsValidPlacement);
                    OnPlacement.OnNext(be);
                }

                if (be != null && be.DoDestroy) {
                    be.Builder.Message(be.DestroyReason);
                    UnityEngine.Object.Destroy(gameObject);
                    return null;
                }

                return gameObject.GetComponent<BaseEntity>();
            } catch (Exception ex) {
                Logger.LogException(ex);
                return null;
            }
        }