Exemplo n.º 1
0
        private void OnPlaced()
        {
            base.enabled = false;
            Transform child = this._ghosts[this._currentGhost]._go.transform.GetChild(0);

            if (!BoltNetwork.isRunning)
            {
                if (LocalPlayer.Create.BuildingPlacer.LastHit != null && LocalPlayer.Create.BuildingPlacer.LastHit.Value.transform.GetComponentInParent <BoltEntity>())
                {
                    child.parent = LocalPlayer.Create.BuildingPlacer.LastHit.Value.transform.GetComponentInParent <BoltEntity>().transform;
                }
                else
                {
                    child.parent = null;
                }
                child.SendMessage("OnPlaced", SendMessageOptions.DontRequireReceiver);
                GameObject gameObject = child.Find("Trigger").gameObject;
                gameObject.SetActive(true);
                if (this._ghosts[this._currentGhost]._initialize)
                {
                    gameObject.GetComponent <Craft_Structure>().Initialize();
                }
                UnityEngine.Object.Destroy(base.gameObject);
            }
            else
            {
                CoopConstructionEx component = child.GetComponent <CoopConstructionEx>();
                if (component)
                {
                    BoltEntity component2   = child.GetComponent <BoltEntity>();
                    BoltEntity parentEntity = LocalPlayer.Create.GetParentEntity(child.gameObject);
                    component.SendMessage("OnSerializing");
                    CoopConstructionExToken coopConstructionExToken = LocalPlayer.Create.GetCoopConstructionExToken(component, parentEntity);
                    PlaceFoundationEx       placeFoundationEx       = PlaceFoundationEx.Create(GlobalTargets.OnlyServer);
                    placeFoundationEx.Parent   = parentEntity;
                    placeFoundationEx.Position = child.transform.position;
                    placeFoundationEx.Prefab   = component2.prefabId;
                    placeFoundationEx.Token    = coopConstructionExToken;
                    placeFoundationEx.Send();
                }
                else
                {
                    PlaceConstruction placeConstruction = PlaceConstruction.Create(GlobalTargets.OnlyServer);
                    if (LocalPlayer.Create.BuildingPlacer.LastHit != null)
                    {
                        placeConstruction.Parent = LocalPlayer.Create.BuildingPlacer.LastHit.Value.transform.GetComponentInParent <BoltEntity>();
                    }
                    placeConstruction.PrefabId = child.GetComponent <BoltEntity>().prefabId;
                    placeConstruction.Position = child.position;
                    placeConstruction.Rotation = child.rotation;
                    FoundationArchitect component3 = child.GetComponent <FoundationArchitect>();
                    if (component3)
                    {
                        placeConstruction.AboveGround = component3._aboveGround;
                    }
                    placeConstruction.Send();
                }
                UnityEngine.Object.Destroy(base.gameObject, 0.05f);
            }
        }
Exemplo n.º 2
0
 public void LocalizedHit(LocalizedHitData data)
 {
     if (!PlayerPreferences.NoDestruction)
     {
         if (BoltNetwork.isClient)
         {
             if (this._owner)
             {
                 FoundationArchitect foundation = this._owner._foundation;
                 if (foundation)
                 {
                     FoundationExLocalizedHit foundationExLocalizedHit = FoundationExLocalizedHit.Create(GlobalTargets.OnlyServer);
                     foundationExLocalizedHit.Entity      = base.GetComponentInParent <BoltEntity>();
                     foundationExLocalizedHit.Chunk       = foundation.GetChunkIndex(this);
                     foundationExLocalizedHit.HitDamage   = data._damage;
                     foundationExLocalizedHit.HitPosition = data._position;
                     foundationExLocalizedHit.Send();
                     Prefabs.Instance.SpawnHitPS(HitParticles.Wood, data._position, Quaternion.LookRotation(base.transform.right));
                     this._owner.Distort(data);
                 }
             }
         }
         else
         {
             this.LocalizedHitReal(data);
         }
     }
 }
Exemplo n.º 3
0
    public override void OnEvent(PlaceConstruction evnt)
    {
        BoltEntity boltEntity = BoltNetwork.Instantiate(evnt.PrefabId, evnt.Position, evnt.Rotation);

        if (boltEntity.GetComponent <TreeStructure>())
        {
            boltEntity.GetComponent <TreeStructure>().TreeId = evnt.TreeIndex;
        }
        if (evnt.Parent)
        {
            boltEntity.transform.parent = evnt.Parent.transform;
        }
        if (evnt.AboveGround)
        {
            FoundationArchitect component = boltEntity.GetComponent <FoundationArchitect>();
            if (component)
            {
                component._aboveGround = evnt.AboveGround;
            }
        }
        boltEntity.SendMessage("OnDeserialized", SendMessageOptions.DontRequireReceiver);
        LocalPlayer.Create.RefreshGrabber();
    }