Example #1
0
        public void NetSpawn(EntityId targetId, Vec3 pos)
        {
            var tank = Entity.Get<Tank>(targetId);

            tank.Position = pos;

            tank.OnRevive();
        }
Example #2
0
        protected override void OnCollision(EntityId targetEntityId, Vec3 hitPos, Vec3 dir, short materialId, Vec3 contactNormal)
        {
            if(Velocity.Length > VelocityToKill)
            {
                var particle = ParticleEffect.Get("explosions.barrel.explode");
                particle.Spawn(hitPos);

                Entity.Remove(Id);
            }
        }
Example #3
0
        public override void OnRevive(EntityId actorId, Vec3 pos, Vec3 rot, int teamId)
        {
            var player = Actor.Get<Player>(actorId);

            if(player == null)
            {
                Debug.Log("[SinglePlayer.OnRevive] Failed to get the player. Check the log for errors.");
                return;
            }
        }
Example #4
0
        public override void OnRevive(EntityId actorId, Vec3 pos, Vec3 rot, int teamId)
        {
            var cameraProxy = Actor.Get(actorId) as PlayerCamera;
            if(cameraProxy == null)
            {
                Debug.Log("[SinglePlayer.OnRevive] Failed to get the player proxy. Check the log for errors.");
                return;
            }

            cameraProxy.Init();
        }
Example #5
0
 protected override void OnCollision(EntityId targetEntityId, Vec3 hitPos, Vec3 dir, short materialId, Vec3 contactNormal)
 {
     // Hit something, reset last event time.
     if(state == BoidState.Launched)
     {
         if(postFire == null)
             postFire = new DelayedFunc(OnStoppedMoving, 4000);
         else
             postFire.Reset();
     }
 }
Example #6
0
        public virtual void RevivePlayer(EntityId actorId)
        {
            var tank = Actor.Get<Tank>(actorId);
            if(tank == null)
            {
                Debug.Log("[SinglePlayer.OnRevive] Failed to get the player. Check the log for errors.");
                return;
            }

            var spawnpoints = Entity.GetByClass<SpawnPoint>();
            if(spawnpoints.Count() > 0)
            {
                var spawnPoint = spawnpoints.ElementAt(Selector.Next(0, spawnpoints.Count() - 1));

                spawnPoint.TrySpawn(tank);
            }
        }
        protected override void OnCollision(EntityId targetEntityId, Vec3 hitPos, Vec3 dir, short materialId, Vec3 contactNormal)
        {
            if (!Destroyed && targetEntityId!=0)
            {
                var breakageParams = new BreakageParameters();
                breakageParams.type = BreakageType.Destroy;
                breakageParams.fParticleLifeTime = 7.0f;
                breakageParams.bMaterialEffects = true;
                breakageParams.nGenericCount = 0;
                breakageParams.bForceEntity = false;
                breakageParams.bOnlyHelperPieces = false;

                breakageParams.fExplodeImpulse = 10.0f;
                breakageParams.vHitImpulse = dir;
                breakageParams.vHitPoint = hitPos;

                Physics.Break(breakageParams);

                SetSlotFlags(GetSlotFlags() | EntitySlotFlags.Render);

                Destroyed = true;
            }
        }
Example #8
0
 /// <summary>
 /// Called when another entity is no longer close to the area linked to this entity.
 /// </summary>
 /// <param name="entityId">EntityId of the entity in our area</param>
 /// <param name="areaId">Area identifier</param>
 /// <param name="areaEntityId">Entity identifier assigned to the area (normally ours)</param>
 protected virtual void OnLeaveNearArea(EntityId entityId, int areaId, EntityId areaEntityId)
 {
 }
Example #9
0
        /// <summary>
        /// Initializes the player.
        /// </summary>
        /// <param name="actorInfo"></param>
        internal virtual void InternalSpawn(ActorInfo actorInfo)
        {
            System.Diagnostics.Contracts.Contract.Requires(actorInfo.ChannelId > 0);
            Id = new EntityId(actorInfo.Id);
            this.SetActorHandle(actorInfo.ActorPtr);
            this.SetEntityHandle(actorInfo.EntityPtr);

            ChannelId = actorInfo.ChannelId;

            // actor must have physics
            Physics.Type = PhysicalizationType.Rigid;

            OnSpawn();
        }
Example #10
0
 public void SwitchToEntityObject(EntityId entityId)
 {
     NativeEntityMethods.BindAttachmentToEntity(Handle, entityId);
 }
Example #11
0
 internal NativeActor(ActorInfo actorInfo)
 {
     Id = new EntityId(actorInfo.Id);
     this.SetIEntity(actorInfo.EntityPtr);
     this.SetIActor(actorInfo.ActorPtr);
 }
Example #12
0
 /// <summary>
 /// Called when another entity gets close to the area linked to this entity.
 /// </summary>
 /// <param name="entityId">EntityId of the entity in our area</param>
 /// <param name="areaId">Area identifier</param>
 /// <param name="areaEntityId">Entity identifier assigned to the area (normally ours)</param>
 /// <param name="distance">Distance to our area</param>
 protected virtual void OnEnterNearArea(EntityId entityId, int areaId, EntityId areaEntityId, float distance)
 {
 }
Example #13
0
 internal NativeActor(EntityId id)
 {
     Id = id;
 }
Example #14
0
 /// <summary>
 /// Called whenever another entity has been unlinked from this entity.
 /// </summary>
 /// <param name="child"></param>
 protected virtual void OnDetach(EntityId child)
 {
 }
Example #15
0
 /// <summary>
 /// Sent when entity leaves the area proximity.
 /// </summary>
 /// <param name="entityId"></param>
 /// <param name="areaEntityId"></param>
 /// <param name="fade"></param>
 protected virtual void OnLeaveArea(EntityId entityId, int areaEntityId, float fade)
 {
 }
Example #16
0
 /// <summary>
 /// Sent when entity enters to the area proximity.
 /// </summary>
 /// <param name="entityId"></param>
 protected virtual void OnEnterArea(EntityId entityId, int areaId, EntityId areaEntityId)
 {
 }
Example #17
0
 /// <summary>
 /// Called when another entity moves inside the area linked to this entity.
 /// </summary>
 /// <param name="entityId">EntityId of the entity in our area</param>
 /// <param name="areaId">Area identifier</param>
 /// <param name="areaEntityId">Entity identifier assigned to the area (normally ours)</param>
 protected virtual void OnMoveInsideArea(EntityId entityId, int areaId, EntityId areaEntityId)
 {
 }
Example #18
0
 /// <summary>
 /// Sent on entity collision.
 /// </summary>
 /// <param name="colliderId"></param>
 /// <param name="hitPos"></param>
 /// <param name="dir"></param>
 /// <param name="materialId"></param>
 /// <param name="contactNormal"></param>
 protected virtual void OnCollision(EntityId colliderId, Vec3 hitPos, Vec3 dir, short materialId, Vec3 contactNormal)
 {
 }
Example #19
0
 /// <summary>
 /// Called when another entity enters an area linked to this entity.
 /// </summary>
 /// <param name="entityId">EntityId of the entity in our area</param>
 /// <param name="areaId">Area identifier</param>
 /// <param name="areaEntityId">Entity identifier assigned to the area (normally ours)</param>
 protected virtual void OnEnterArea(EntityId entityId, int areaId, EntityId areaEntityId)
 {
 }
Example #20
0
 /// <summary>
 /// Removes an actor by entity id.
 /// </summary>
 /// <param name="id"></param>
 public static void Remove(EntityId id)
 {
     NativeActorMethods.RemoveActor(id);
 }
Example #21
0
 /// <summary>
 /// Remove the entity with the specified id.
 /// </summary>
 /// <param name="id"></param>
 public static void Remove(EntityId id)
 {
     Global.gEnv.pEntitySystem.RemoveEntity(id);
 }
Example #22
0
 public override void OnClientEnteredGame(int channelId, EntityId playerId, bool reset, bool loadingSaveGame)
 {
     if(!Network.IsEditor)
         RevivePlayer(playerId);
 }
Example #23
0
 /// <summary>
 /// Sent when entity moves inside the area proximity.
 /// </summary>
 /// <param name="entityId"></param>
 protected virtual void OnMoveInsideArea(EntityId entityId, int areaId, EntityId areaEntityId)
 {
 }
Example #24
0
 public override void OnRevive(EntityId actorId, Vec3 pos, Vec3 rot, int teamId)
 {
     if(Network.IsEditor)
         RevivePlayer(actorId);
 }
Example #25
0
 internal NativeActor(ActorInitializationParams actorInfo)
 {
     Id = new EntityId(actorInfo.Id);
     this.SetIEntity(actorInfo.EntityPtr);
     this.SetIActor(actorInfo.ActorPtr);
 }
 internal NativeActor(ActorInitializationParams actorInfo)
 {
     Id = new EntityId(actorInfo.Id);
     this.SetIEntity(actorInfo.EntityPtr);
     this.SetIActor(actorInfo.ActorPtr);
 }
Example #27
0
 public NativeEntity(EntityId id, IntPtr ptr)
 {
     Id = id;
     this.SetIEntity(ptr);
 }
Example #28
0
 protected virtual void OnEnterNearArea(EntityId entityId, int areaId, float fade)
 {
 }
Example #29
0
        protected override void OnCollision(EntityId targetEntityId, Vec3 hitPos, Vec3 dir, short materialId, Vec3 contactNormal)
        {
            var effect = ParticleEffect.Get(Effect);
            effect.Spawn(hitPos, contactNormal, EffectScale);

            // Id 0 is the terrain
            if(targetEntityId != 0)
            {
                var target = Entity.Get(targetEntityId) as IDamageable;

                if(target != null)
                    target.Damage(Damage, DamageType);
            }

            if(ShouldExplode)
            {
                var explosion = new Explosion
                {
                    Epicenter = Position,
                    EpicenterImpulse = Position,
                    Direction = dir,
                    MinRadius = MinimumExplosionRadius,
                    Radius = ExplosionRadius,
                    MaxRadius = MaximumExplosionRadius,
                    ImpulsePressure = ExplosionPressure
                };

                explosion.Explode();
            }

            Remove();
        }
Example #30
0
 /// <summary>
 /// Sent when entity moves inside the area proximity.
 /// </summary>
 /// <param name="entityId"></param>
 /// <param name="areaId"></param>
 /// <param name="fade"></param>
 protected virtual void OnMoveInsideArea(EntityId entityId, int areaId, float fade)
 {
 }
Example #31
0
 internal NativeActor(ActorInfo actorInfo)
 {
     Id = new EntityId(actorInfo.Id);
     this.SetEntityHandle(actorInfo.EntityPtr);
     this.SetActorHandle(actorInfo.ActorPtr);
 }
Example #32
0
 protected virtual void OnLeaveNearArea(EntityId entityId, int areaId, EntityId areaEntityId)
 {
 }
        protected override void OnEnterArea(EntityId entityId, int areaEntityId, float fade)
        {
            // Pick up if active

            if(Active)
            {
                var entity = Entity.Get(entityId);

                if (entity is Tank)
                {
                    LastUser = entity as Tank;

                    Debug.DrawText(string.Format("{0} GOT A {1} COLLECTIBLE!", entity.Name.ToUpper(), Collectible.TypeName.ToUpper()), 3.0f, Color.Red, 2.0f);
                    Collectible.OnCollected(LastUser);

                    //Debug.DrawText("nom nom nom", 3.0f, Color.Blue, 5.0f);
                }
                else
                    return;

                LastUsage = Time.FrameStartTime;

                Material = Material.Find("objects/tank_gameplay_assets/pickup_hologram/pickups_off");
                Active = false;
            }
        }
Example #34
0
 protected virtual void OnMoveNearArea(EntityId entityId, int areaId, EntityId areaEntityId, float fade)
 {
 }
Example #35
0
 public override void OnClientEnteredGame(int channelId, EntityId playerId, bool reset, bool loadingSaveGame)
 {
     Network.RemoteInvocation(OtherClientEnteredGame, NetworkTarget.ToOtherClients, channelId, playerId);
 }
Example #36
0
 /// <summary>
 /// Called whenever this entity is unliked from another entity.
 /// </summary>
 /// <param name="parent"></param>
 protected virtual void OnDetachThis(EntityId parent)
 {
 }
Example #37
0
 public void OtherClientEnteredGame(int channelId, EntityId playerId)
 {
     Debug.LogAlways("Other client with channelId {0} and playerId {1} entered the game", channelId, playerId);
 }
Example #38
0
 internal NativeActor(EntityId id)
 {
     Id = id;
 }
Example #39
0
 /// <summary>
 /// Called when another entity moves inside the near area linked to this entity.
 /// </summary>
 /// <param name="entityId">EntityId of the entity in our area</param>
 /// <param name="areaId">Area identifier</param>
 /// <param name="areaEntityId">Entity identifier assigned to the area (normally ours)</param>
 /// <param name="fadeRatio">Fade ratio (0 to 1)</param>
 protected virtual void OnMoveNearArea(EntityId entityId, int areaId, EntityId areaEntityId, float fadeRatio)
 {
 }