Example #1
0
        public override bool Equals(object other)
        {
            if (!(other is SerializedQuaternion))
            {
                return(false);
            }
            SerializedQuaternion q = (SerializedQuaternion)other;

            return(x.Equals(q.x) && y.Equals(q.y) && z.Equals(q.z) && w.Equals(q.w));
        }
 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(Deployable deployable)
 {
     if (Origo == null)
     {
         Origo = new Origo(new SerializedVector3(deployable.transform.position), new SerializedQuaternion(deployable.transform.rotation));
     }
     var v3 = new SerializedVector3(deployable.transform.position - Origo.Position.ToVector3());
     var q = new SerializedQuaternion(deployable.transform.rotation);
     var component = new DeployableComponent(deployable, v3, q);
     if (component == null)
     {
         Pluton.Logger.LogDebug("[StructureRecorder] Deployable component is null!");
         return;
     }
     if (!DeployableComponents.ContainsKey(component.ToString()))
     {
         DeployableComponents.Add(component.ToString(), component);
     }
     else
     {
         DeployableComponents[component.ToString()] = component;
     }
 }
 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;
     }
 }
 public StructureComponent(string str, SerializedVector3 v3, SerializedQuaternion q, int i)
 {
     throw new NotImplementedException();
 }
Example #6
0
 public bool Equals(SerializedQuaternion q)
 {
     return(q.ToQuaternion().Equals(ToQuaternion()));
 }
 public void RemoveComponent(Spawnable spawnable)
 {
     var v3 = new SerializedVector3(spawnable.transform.position - Origo.Position.ToVector3());
     var q = new SerializedQuaternion(spawnable.transform.rotation);
     var component = new SpawnableComponent(spawnable, v3, q);
     if (SpawnableComponents.ContainsKey(component.ToString()))
     {
         SpawnableComponents.Remove(component.ToString());
     }
 }
 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());
     }
 }
 public SpawnableComponent(Spawnable spawnable, SerializedVector3 v3, SerializedQuaternion q)
 {
     Prefab = spawnable.GetComponent<BaseNetworkable>().LookupPrefabName();
     LocalPosition = v3;
     LocalRotation = q;
 }
 public Origo(SerializedVector3 v3, SerializedQuaternion q)
 {
     Position = v3;
     Rotation = q;
 }
Example #11
0
 public bool Equals(SerializedQuaternion q)
 {
     return q.ToQuaternion().Equals(ToQuaternion());
 }