Пример #1
0
        // BuildingBlock.BecomeFrame()
        public static void EntityFrameDeployed(BuildingBlock bb)
        {
            // blockDefinition is null in this hook, but works

            var bp = new BuildingPart(bb);

            OnBuildingFrameDeployed.OnNext(bp);
        }
Пример #2
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 StructureComponent(BuildingPart bp, SerializedVector3 v3, SerializedQuaternion q)
 {
     Grade = bp.buildingBlock.grade;
     Prefab = bp.buildingBlock.LookupPrefabName();
     LocalPosition = v3;
     LocalRotation = q;
     Health = (float)((int)Math.Floor((double)(bp.Health / 85)) * 85);
     if (bp.buildingBlock.HasSlot(BaseEntity.Slot.Lock))
     {
         var baseLock = bp.buildingBlock.GetSlot(BaseEntity.Slot.Lock) as BaseLock;
         if (baseLock == null)
         {
             HasCodeLock = false;
             HasKeyLock = false;
         }
         else if (baseLock.GetComponent<CodeLock>())
         {
             HasCodeLock = true;
             HasKeyLock = false;
             CodeLock codeLock = baseLock.GetComponent<CodeLock>();
             if (!string.IsNullOrEmpty((string)codeLock.GetFieldValue("code")))
             {
                 LockCode = (string)codeLock.GetFieldValue("code");
                 LockWList = new List<ulong>();
                 LockWList = (List<ulong>)codeLock.GetFieldValue("whitelistPlayers");
             }
         }
         else if (baseLock.GetComponent<KeyLock>())
         {
             HasCodeLock = false;
             HasKeyLock = true;
             KeyLock keyLock = baseLock.GetComponent<KeyLock>();
             int keyCode = (int)keyLock.GetFieldValue("keyCode");
             keyCode = (bool)keyLock.GetFieldValue("firstKeyCreated") ? keyCode |= 0x80 : (int)keyLock.GetFieldValue("keyCode");
             LockCode = keyCode.ToString();
         }
     }
 }
 public void AddComponent(BuildingPart bp)
 {
     if (Origo == null)
     {
         Origo = new Origo(new SerializedVector3(bp.Location), new SerializedQuaternion(bp.buildingBlock.transform.rotation));
     }
     var v3 = new SerializedVector3(bp.Location - Origo.Position.ToVector3());
     var q = new SerializedQuaternion(bp.buildingBlock.transform.rotation);
     var component = new StructureComponent(bp, v3, q);
     if (component == null)
     {
         Pluton.Logger.LogDebug("[StructureRecorder] BuildingPart component is null!");
         return;
     }
     if (!StructureComponents.ContainsKey(component.ToString()))
     {
         StructureComponents.Add(component.ToString(), component);
     }
     else
     {
         StructureComponents[component.ToString()] = component;
     }
 }
Пример #5
0
        // BuildingBlock.OnAttacked()
        public static void EntityAttacked(BuildingBlock bb, HitInfo info)
        {
            // works, event needed
            if (info.Initiator != null)
            {
                Player      p     = new Player(info.Initiator as BasePlayer);
                PlayerStats stats = new PlayerStats(p.SteamID);
                stats.AddDamageTo(info.damageAmount, false, false, true);
                p.Stats = stats;
            }

            var bp = new BuildingPart(bb);

            // if entity will be destroyed call the method below
            if ((bb.health - info.damageAmount) <= 0.0f)
            {
                BuildingPartDestroyed(bp, info);
                if ((bb.health - info.damageAmount) <= 0.0f)
                {
                    return;
                }
            }
            OnBuildingPartAttacked.OnNext(new BuildingHurtEvent(bp, info));
        }
Пример #6
0
        // BuildingBlock.BecomeBuilt()
        public static void EntityBuilt(BuildingBlock bb)
        {
            var bp = new BuildingPart(bb);

            OnBuildingComplete.OnNext(bp);
        }
Пример #7
0
 public static void BuildingPartDestroyed(BuildingPart bp, HitInfo info)
 {
     OnBuildingPartDestroyed.OnNext(new BuildingHurtEvent(bp, info));
 }
 public void RemoveComponent(BuildingPart bp)
 {
     var v3 = new SerializedVector3(bp.Location - Origo.Position.ToVector3());
     var q = new SerializedQuaternion(bp.buildingBlock.transform.rotation);
     var component = new StructureComponent(bp, v3, q);
     if (StructureComponents.ContainsKey(component.ToString()))
     {
         StructureComponents.Remove(component.ToString());
     }
 }
Пример #9
0
 public void OnBuildingComplete(BuildingPart bp)
 {
     this.Invoke("On_BuildingComplete", bp);
 }
Пример #10
0
 public void OnFrameDeployed(BuildingPart bp)
 {
     this.Invoke("On_FrameDeployed", bp);
 }