Ejemplo n.º 1
0
        public AmmunitionObsoleteStats(AmmunitionObsoleteSerializable serializable, Database.Loader loader)
        {
            AmmunitionClass     = serializable.AmmunitionClass;
            DamageType          = serializable.DamageType;
            Impulse             = UnityEngine.Mathf.Clamp(serializable.Impulse, 0f, 10f);
            Recoil              = UnityEngine.Mathf.Clamp(serializable.Recoil, 0f, 10f);
            Size                = UnityEngine.Mathf.Clamp(serializable.Size, 0f, 1000f);
            InitialPosition     = serializable.InitialPosition;
            AreaOfEffect        = UnityEngine.Mathf.Clamp(serializable.AreaOfEffect, 0f, 1000f);
            Damage              = UnityEngine.Mathf.Clamp(serializable.Damage, 0f, 1E+09f);
            Range               = UnityEngine.Mathf.Clamp(serializable.Range, 0f, 1000f);
            Velocity            = UnityEngine.Mathf.Clamp(serializable.Velocity, 0f, 1000f);
            LifeTime            = UnityEngine.Mathf.Clamp(serializable.LifeTime, 0f, 1E+09f);
            HitPoints           = UnityEngine.Mathf.Clamp(serializable.HitPoints, 0, 999999999);
            IgnoresShipVelocity = serializable.IgnoresShipVelocity;
            EnergyCost          = UnityEngine.Mathf.Clamp(serializable.EnergyCost, 0f, 1E+09f);
            CoupledAmmunition   = loader.GetAmmunitionObsolete(new ItemId <AmmunitionObsolete>(serializable.CoupledAmmunitionId));
            Color               = new ColorData(serializable.Color);
            FireSound           = new AudioClipId(serializable.FireSound);
            HitSound            = new AudioClipId(serializable.HitSound);
            HitEffectPrefab     = new PrefabId(serializable.HitEffectPrefab, PrefabId.Type.Effect);
            BulletPrefab        = new PrefabId(serializable.BulletPrefab, PrefabId.Type.Bullet);

            OnDataDeserialized(serializable, loader);
        }
Ejemplo n.º 2
0
 public void DumpStr(StringBuilder sb, string prefix)
 {
     sb.AppendLine(prefix + "EntityId" + ":" + EntityId.ToString());
     sb.AppendLine(prefix + "PrefabId" + ":" + PrefabId.ToString());
     sb.AppendLine(prefix + "Timer" + ":" + Timer.ToString());
     sb.AppendLine(prefix + "Info" + ":");  Info.DumpStr(sb, "\t" + prefix);
     sb.AppendLine(prefix + "transform" + ":");  transform.DumpStr(sb, "\t" + prefix);
 }
Ejemplo n.º 3
0
        internal TEntity Create <TEntity>(PrefabId prefabId, Entity.CreateToken createToken = null) where TEntity : Unit
        {
            TEntity entity = BoltNetwork.Instantiate(prefabId, createToken).GetComponent <TEntity>();

            entity.ModifyDeathState(DeathState.Alive);
            entity.Attributes.SetHealth(entity.MaxHealth);
            entity.MovementInfo.HasMovementControl = true;
            return(entity);
        }
Ejemplo n.º 4
0
        public int GetHash(ref int idx)
        {
            int hash = 1;

            hash += EntityId.GetHash(ref idx) * PrimerLUT.GetPrimer(idx++);
            hash += PrefabId.GetHash(ref idx) * PrimerLUT.GetPrimer(idx++);
            hash += Timer.GetHash(ref idx) * PrimerLUT.GetPrimer(idx++);
            hash += Info.GetHash(ref idx) * PrimerLUT.GetPrimer(idx++);
            hash += transform.GetHash(ref idx) * PrimerLUT.GetPrimer(idx++);
            return(hash);
        }
Ejemplo n.º 5
0
        public static BoltEntity Spawn(PrefabId prefabId, Vector3 position, Quaternion rotation)
        {
            if (prefabId == BoltPrefabs.Log)
            {
                var dropItem = DropItem.Create(GlobalTargets.OnlyServer);
                dropItem.PrefabId = prefabId;
                dropItem.Position = position;
                dropItem.Rotation = rotation;
                dropItem.Send();
                return(null);
            }

            return(BoltNetwork.Instantiate(prefabId, position, rotation));
        }
Ejemplo n.º 6
0
        public static void Spawn(PrefabId prefabId, Vector3 position, Quaternion rotation)
        {
            if (prefabId == BoltPrefabs.Log)
            {
                var dropItem = DropItem.Create(GlobalTargets.OnlyServer);
                dropItem.PrefabId = prefabId;
                dropItem.Position = position;
                dropItem.Rotation = rotation;
                PacketQueue.Add(dropItem);
                return;
            }

            BoltNetwork.Instantiate(prefabId, position, rotation);
        }
Ejemplo n.º 7
0
        public GameObject Instantiate(PrefabId prefabId, Vector3 position, Quaternion rotation)
        {
            GameObject gameObject = GameObjectPool.Take(LoadPrefab(prefabId), position, rotation);

            if (!gameObject.CompareTag("Move State"))
            {
                Entity createdEntity = gameObject.GetComponent <Entity>();

                EventHandler.ExecuteEvent(gameObject, GameEvents.EntityPooled, true, world);
                takenEntities.Add(gameObject, createdEntity);
            }

            return(gameObject);
        }
Ejemplo n.º 8
0
        public WeaponStats(WeaponSerializable serializable, Database.Loader loader)
        {
            WeaponClass       = serializable.WeaponClass;
            FireRate          = UnityEngine.Mathf.Clamp(serializable.FireRate, 0f, 100f);
            Spread            = UnityEngine.Mathf.Clamp(serializable.Spread, 0f, 360f);
            Magazine          = UnityEngine.Mathf.Clamp(serializable.Magazine, 0, 999999999);
            ActivationType    = serializable.ActivationType;
            ShotSound         = new AudioClipId(serializable.ShotSound);
            ChargeSound       = new AudioClipId(serializable.ChargeSound);
            ShotEffectPrefab  = new PrefabId(serializable.ShotEffectPrefab, PrefabId.Type.Effect);
            ControlButtonIcon = new SpriteId(serializable.ControlButtonIcon, SpriteId.Type.ActionButton);

            OnDataDeserialized(serializable, loader);
        }
Ejemplo n.º 9
0
        public GameObject Instantiate(PrefabId prefabId, Vector3 position, Quaternion rotation)
        {
            GameObject gameObject = GameObjectPool.Take(LoadPrefab(prefabId), position, rotation);

            if (!gameObject.CompareTag("Move State"))
            {
                Entity createdEntity = gameObject.GetComponent <Entity>();

                createdEntity.TakenFromPool(worldManager);
                takenEntities.Add(gameObject, createdEntity);
            }

            gameObject.transform.SetParent(null);
            return(gameObject);
        }
Ejemplo n.º 10
0
        public DroneBayStats(DroneBaySerializable serializable, Database.Loader loader)
        {
            EnergyConsumption        = UnityEngine.Mathf.Clamp(serializable.EnergyConsumption, 0f, 1E+09f);
            PassiveEnergyConsumption = UnityEngine.Mathf.Clamp(serializable.PassiveEnergyConsumption, 0f, 1E+09f);
            Range              = UnityEngine.Mathf.Clamp(serializable.Range, 1f, 1000f);
            DamageMultiplier   = UnityEngine.Mathf.Clamp(serializable.DamageMultiplier, 0.01f, 1000f);
            DefenseMultiplier  = UnityEngine.Mathf.Clamp(serializable.DefenseMultiplier, 0.01f, 1000f);
            SpeedMultiplier    = UnityEngine.Mathf.Clamp(serializable.SpeedMultiplier, 0.01f, 1000f);
            ImprovedAi         = serializable.ImprovedAi;
            Capacity           = UnityEngine.Mathf.Clamp(serializable.Capacity, 1, 1000);
            ActivationType     = serializable.ActivationType;
            LaunchSound        = new AudioClipId(serializable.LaunchSound);
            LaunchEffectPrefab = new PrefabId(serializable.LaunchEffectPrefab, PrefabId.Type.Effect);
            ControlButtonIcon  = new SpriteId(serializable.ControlButtonIcon, SpriteId.Type.ActionButton);

            OnDataDeserialized(serializable, loader);
        }
Ejemplo n.º 11
0
 public void AttachToNetwork(PrefabId prefabId, UniqueId state, GameObject sourceGo)
 {
     if (BoltNetwork.isServer)
     {
         BoltEntity boltEntity = sourceGo.AddComponent <BoltEntity>();
         using (BoltEntitySettingsModifier boltEntitySettingsModifier = boltEntity.ModifySettings())
         {
             boltEntitySettingsModifier.persistThroughSceneLoads = true;
             boltEntitySettingsModifier.allowInstantiateOnClient = false;
             boltEntitySettingsModifier.clientPredicted          = false;
             boltEntitySettingsModifier.prefabId     = prefabId;
             boltEntitySettingsModifier.updateRate   = 1;
             boltEntitySettingsModifier.sceneId      = UniqueId.None;
             boltEntitySettingsModifier.serializerId = state;
         }
         BoltNetwork.Attach(boltEntity.gameObject);
     }
 }
Ejemplo n.º 12
0
 public void DumpStr(StringBuilder sb, string prefix)
 {
     sb.AppendLine(prefix + "EntityId" + ":" + EntityId.ToString());
     sb.AppendLine(prefix + "PrefabId" + ":" + PrefabId.ToString());
     sb.AppendLine(prefix + "curHealth" + ":" + curHealth.ToString());
     sb.AppendLine(prefix + "damage" + ":" + damage.ToString());
     sb.AppendLine(prefix + "isFire" + ":" + isFire.ToString());
     sb.AppendLine(prefix + "isInvincible" + ":" + isInvincible.ToString());
     sb.AppendLine(prefix + "maxHealth" + ":" + maxHealth.ToString());
     sb.AppendLine(prefix + "moveSpd" + ":" + moveSpd.ToString());
     sb.AppendLine(prefix + "turnSpd" + ":" + turnSpd.ToString());
     sb.AppendLine(prefix + "animator" + ":");  animator.DumpStr(sb, "\t" + prefix);
     sb.AppendLine(prefix + "brain" + ":");  brain.DumpStr(sb, "\t" + prefix);
     sb.AppendLine(prefix + "colliderData" + ":");  colliderData.DumpStr(sb, "\t" + prefix);
     sb.AppendLine(prefix + "rigidbody" + ":");  rigidbody.DumpStr(sb, "\t" + prefix);
     sb.AppendLine(prefix + "skillBox" + ":");  skillBox.DumpStr(sb, "\t" + prefix);
     sb.AppendLine(prefix + "transform" + ":");  transform.DumpStr(sb, "\t" + prefix);
 }
Ejemplo n.º 13
0
        public DeviceStats(DeviceSerializable serializable, Database.Loader loader)
        {
            DeviceClass              = serializable.DeviceClass;
            EnergyConsumption        = UnityEngine.Mathf.Clamp(serializable.EnergyConsumption, 0f, 1E+09f);
            PassiveEnergyConsumption = UnityEngine.Mathf.Clamp(serializable.PassiveEnergyConsumption, 0f, 1E+09f);
            Power             = UnityEngine.Mathf.Clamp(serializable.Power, 0f, 1000f);
            Range             = UnityEngine.Mathf.Clamp(serializable.Range, 0f, 1000f);
            Size              = UnityEngine.Mathf.Clamp(serializable.Size, 0f, 1000f);
            Cooldown          = UnityEngine.Mathf.Clamp(serializable.Cooldown, 0f, 1000f);
            Lifetime          = UnityEngine.Mathf.Clamp(serializable.Lifetime, 0f, 1000f);
            Offset            = serializable.Offset;
            ActivationType    = serializable.ActivationType;
            Color             = new ColorData(serializable.Color);
            Sound             = new AudioClipId(serializable.Sound);
            EffectPrefab      = new PrefabId(serializable.EffectPrefab, PrefabId.Type.Effect);
            ObjectPrefab      = new PrefabId(serializable.ObjectPrefab, PrefabId.Type.Object);
            ControlButtonIcon = new SpriteId(serializable.ControlButtonIcon, SpriteId.Type.ActionButton);

            OnDataDeserialized(serializable, loader);
        }
Ejemplo n.º 14
0
        public IProvider CreateProvider(
            string resourcePath, Type resultType, string gameObjectName, string gameObjectGroupName,
            List <TypeValuePair> extraArguments, object concreteIdentifier)
        {
            IPrefabInstantiator creator;

            _markRegistry.MarkSingleton(
                resultType, concreteIdentifier, SingletonTypes.ToPrefabResource);

            var prefabId = new PrefabId(concreteIdentifier, resourcePath);

            if (_prefabCreators.TryGetValue(prefabId, out creator))
            {
                // TODO: Check the arguments are the same?
                Assert.That(creator.ExtraArguments.IsEmpty() && extraArguments.IsEmpty(),
                            "Ambiguous creation parameters (arguments) when using ToPrefabResource with AsSingle");

                Assert.IsEqual(creator.GameObjectName, gameObjectName,
                               "Ambiguous creation parameters (gameObjectName) when using ToPrefabResource with AsSingle");

                Assert.IsEqual(creator.GameObjectGroupName, gameObjectGroupName,
                               "Ambiguous creation parameters (gameObjectGroupName) when using ToPrefabResource with AsSingle");
            }
            else
            {
                creator = new PrefabInstantiatorCached(
                    new PrefabInstantiator(
                        _container, gameObjectName,
                        gameObjectGroupName, extraArguments,
                        new PrefabProviderResource(resourcePath)));

                _prefabCreators.Add(prefabId, creator);
            }

            if (resultType == typeof(GameObject))
            {
                return(new PrefabGameObjectProvider(creator));
            }

            return(new GetFromPrefabComponentProvider(resultType, creator));
        }
Ejemplo n.º 15
0
        public int GetHash(ref int idx)
        {
            int hash = 1;

            hash += EntityId.GetHash(ref idx) * PrimerLUT.GetPrimer(idx++);
            hash += PrefabId.GetHash(ref idx) * PrimerLUT.GetPrimer(idx++);
            hash += curHealth.GetHash(ref idx) * PrimerLUT.GetPrimer(idx++);
            hash += damage.GetHash(ref idx) * PrimerLUT.GetPrimer(idx++);
            hash += isFire.GetHash(ref idx) * PrimerLUT.GetPrimer(idx++);
            hash += isInvincible.GetHash(ref idx) * PrimerLUT.GetPrimer(idx++);
            hash += maxHealth.GetHash(ref idx) * PrimerLUT.GetPrimer(idx++);
            hash += moveSpd.GetHash(ref idx) * PrimerLUT.GetPrimer(idx++);
            hash += turnSpd.GetHash(ref idx) * PrimerLUT.GetPrimer(idx++);
            hash += animator.GetHash(ref idx) * PrimerLUT.GetPrimer(idx++);
            hash += brain.GetHash(ref idx) * PrimerLUT.GetPrimer(idx++);
            hash += colliderData.GetHash(ref idx) * PrimerLUT.GetPrimer(idx++);
            hash += rigidbody.GetHash(ref idx) * PrimerLUT.GetPrimer(idx++);
            hash += skillBox.GetHash(ref idx) * PrimerLUT.GetPrimer(idx++);
            hash += transform.GetHash(ref idx) * PrimerLUT.GetPrimer(idx++);
            return(hash);
        }
Ejemplo n.º 16
0
    public void DoSpawnCutTree()
    {
        if (BoltNetwork.isRunning)
        {
            return;
        }
        EventInstance windEvent = TreeWindSfx.BeginTransfer(base.transform);

        this.Trunk = (GameObject)UnityEngine.Object.Instantiate(this.Trunk, base.transform.position, base.transform.rotation);
        if (!this.dontScaleTrunk)
        {
            this.Trunk.transform.localScale = base.transform.localScale;
        }
        TreeHealth component = this.Trunk.GetComponent <TreeHealth>();

        component.SetLodBase(this.LodTree);
        UnityEngine.Object.Destroy(base.gameObject);
        PrefabId log = BoltPrefabs.Log;

        TreeWindSfx.CompleteTransfer(this.Trunk.transform, windEvent);
    }
        public IProvider CreateProvider(
            UnityEngine.Object prefab, Type resultType, GameObjectCreationParameters gameObjectBindInfo,
            List <TypeValuePair> extraArguments, object concreteIdentifier, Func <Type, IPrefabInstantiator, IProvider> providerFactory)
        {
            IPrefabInstantiator creator;

            var prefabId = new PrefabId(concreteIdentifier, prefab);

            _markRegistry.MarkSingleton(
                resultType, concreteIdentifier, SingletonTypes.FromPrefab);

            if (_prefabCreators.TryGetValue(prefabId, out creator))
            {
                // TODO: Check the arguments are the same?
                Assert.That(creator.ExtraArguments.IsEmpty() && extraArguments.IsEmpty(),
                            "Ambiguous creation parameters (arguments) when using ToPrefab with AsSingle");

                Assert.IsEqual(creator.GameObjectCreationParameters, gameObjectBindInfo,
                               "Ambiguous creation parameters (game object naming/parent info) when using ToPrefab with AsSingle");
            }
            else
            {
                creator = new PrefabInstantiatorCached(
                    new PrefabInstantiator(
                        _container, gameObjectBindInfo, resultType, extraArguments, new PrefabProvider(prefab)));

                _prefabCreators.Add(prefabId, creator);
            }

            if (resultType == typeof(GameObject))
            {
                return(new PrefabGameObjectProvider(creator));
            }

            return(providerFactory(resultType, creator));
        }
Ejemplo n.º 18
0
 public GameObject LoadPrefab(PrefabId prefabId)
 {
     return(PrefabDatabase.Find(prefabId));
 }
Ejemplo n.º 19
0
        private void ToggleBackToWall()
        {
            WallDefensiveGateArchitect component = base.GetComponent <WallDefensiveGateArchitect>();

            if (component.WasBuilt)
            {
                UnityEngine.Object.Destroy(this);
            }
            else
            {
                bool    is2Sided = component.Is2Sided;
                Vector3 vector   = (!is2Sided) ? component.P2 : Vector3.Lerp(component.P1, component.P2, 0.5f);
                if (BoltNetwork.isRunning)
                {
                    PrefabId           prefabId           = Prefabs.Instance.WallDefensiveChunkGhostPrefab.GetComponent <BoltEntity>().prefabId;
                    PlaceWallChunk     placeWallChunk     = PlaceWallChunk.Create(GlobalTargets.OnlyServer);
                    CoopWallChunkToken coopWallChunkToken = new CoopWallChunkToken();
                    coopWallChunkToken.P1 = component.P1;
                    coopWallChunkToken.P2 = vector;
                    coopWallChunkToken.PointsPositions = null;
                    coopWallChunkToken.Additions       = WallChunkArchitect.Additions.Wall;
                    coopWallChunkToken.Height          = component.Height;
                    placeWallChunk.parent  = ((!base.transform.parent) ? null : base.transform.parent.GetComponentInParent <BoltEntity>());
                    placeWallChunk.token   = coopWallChunkToken;
                    placeWallChunk.prefab  = prefabId;
                    placeWallChunk.support = null;
                    placeWallChunk.Send();
                    if (is2Sided)
                    {
                        PlaceWallChunk     placeWallChunk2     = PlaceWallChunk.Create(GlobalTargets.OnlyServer);
                        CoopWallChunkToken coopWallChunkToken2 = new CoopWallChunkToken();
                        coopWallChunkToken2.P1 = vector;
                        coopWallChunkToken2.P2 = component.P2;
                        coopWallChunkToken2.PointsPositions = null;
                        coopWallChunkToken2.Additions       = WallChunkArchitect.Additions.Wall;
                        coopWallChunkToken2.Height          = component.Height;
                        placeWallChunk2.parent  = ((!base.transform.parent) ? null : base.transform.parent.GetComponentInParent <BoltEntity>());
                        placeWallChunk2.token   = coopWallChunkToken2;
                        placeWallChunk2.prefab  = prefabId;
                        placeWallChunk2.support = null;
                        placeWallChunk2.Send();
                    }
                }
                else
                {
                    WallChunkArchitect wallChunkArchitect = UnityEngine.Object.Instantiate <WallDefensiveChunkArchitect>(Prefabs.Instance.WallDefensiveChunkGhostPrefab);
                    if (base.transform.parent)
                    {
                        wallChunkArchitect.transform.parent = base.transform.parent;
                    }
                    wallChunkArchitect.transform.position = component.P1;
                    wallChunkArchitect.transform.LookAt(vector);
                    wallChunkArchitect.MultipointPositions = null;
                    wallChunkArchitect.P1             = component.P1;
                    wallChunkArchitect.P2             = vector;
                    wallChunkArchitect.CurrentSupport = component.CurrentSupport;
                    wallChunkArchitect.Height         = component.Height;
                    if (is2Sided)
                    {
                        WallChunkArchitect wallChunkArchitect2 = UnityEngine.Object.Instantiate <WallDefensiveChunkArchitect>(Prefabs.Instance.WallDefensiveChunkGhostPrefab);
                        if (base.transform.parent)
                        {
                            wallChunkArchitect2.transform.parent = base.transform.parent;
                        }
                        wallChunkArchitect2.transform.position = vector;
                        wallChunkArchitect2.transform.LookAt(component.P2);
                        wallChunkArchitect2.MultipointPositions = null;
                        wallChunkArchitect2.P1             = vector;
                        wallChunkArchitect2.P2             = component.P2;
                        wallChunkArchitect2.CurrentSupport = component.CurrentSupport;
                    }
                }
                base.StartCoroutine(this.DelayedCancelGhost());
            }
        }
Ejemplo n.º 20
0
 public static void Spawn(PrefabId prefabId, Transform transform)
 {
     Spawn(prefabId, transform.position, transform.rotation);
 }
Ejemplo n.º 21
0
 public static BoltEntity Spawn(PrefabId prefabId, Transform transform)
 {
     return(Spawn(prefabId, transform.position, transform.rotation));
 }
Ejemplo n.º 22
0
 void Awake()
 {
     Id = this.target as PrefabId;
 }