public void NetSpawn(EntityId targetId, Vec3 pos) { var tank = Entity.Get<Tank>(targetId); tank.Position = pos; tank.OnRevive(); }
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); } }
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; } }
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(); }
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(); } }
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; } }
/// <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) { }
/// <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(); }
public void SwitchToEntityObject(EntityId entityId) { NativeEntityMethods.BindAttachmentToEntity(Handle, entityId); }
internal NativeActor(ActorInfo actorInfo) { Id = new EntityId(actorInfo.Id); this.SetIEntity(actorInfo.EntityPtr); this.SetIActor(actorInfo.ActorPtr); }
/// <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) { }
internal NativeActor(EntityId id) { Id = id; }
/// <summary> /// Called whenever another entity has been unlinked from this entity. /// </summary> /// <param name="child"></param> protected virtual void OnDetach(EntityId child) { }
/// <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) { }
/// <summary> /// Sent when entity enters to the area proximity. /// </summary> /// <param name="entityId"></param> protected virtual void OnEnterArea(EntityId entityId, int areaId, EntityId areaEntityId) { }
/// <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) { }
/// <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) { }
/// <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) { }
/// <summary> /// Removes an actor by entity id. /// </summary> /// <param name="id"></param> public static void Remove(EntityId id) { NativeActorMethods.RemoveActor(id); }
/// <summary> /// Remove the entity with the specified id. /// </summary> /// <param name="id"></param> public static void Remove(EntityId id) { Global.gEnv.pEntitySystem.RemoveEntity(id); }
public override void OnClientEnteredGame(int channelId, EntityId playerId, bool reset, bool loadingSaveGame) { if(!Network.IsEditor) RevivePlayer(playerId); }
/// <summary> /// Sent when entity moves inside the area proximity. /// </summary> /// <param name="entityId"></param> protected virtual void OnMoveInsideArea(EntityId entityId, int areaId, EntityId areaEntityId) { }
public override void OnRevive(EntityId actorId, Vec3 pos, Vec3 rot, int teamId) { if(Network.IsEditor) RevivePlayer(actorId); }
internal NativeActor(ActorInitializationParams actorInfo) { Id = new EntityId(actorInfo.Id); this.SetIEntity(actorInfo.EntityPtr); this.SetIActor(actorInfo.ActorPtr); }
public NativeEntity(EntityId id, IntPtr ptr) { Id = id; this.SetIEntity(ptr); }
protected virtual void OnEnterNearArea(EntityId entityId, int areaId, float fade) { }
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(); }
/// <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) { }
internal NativeActor(ActorInfo actorInfo) { Id = new EntityId(actorInfo.Id); this.SetEntityHandle(actorInfo.EntityPtr); this.SetActorHandle(actorInfo.ActorPtr); }
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; } }
protected virtual void OnMoveNearArea(EntityId entityId, int areaId, EntityId areaEntityId, float fade) { }
public override void OnClientEnteredGame(int channelId, EntityId playerId, bool reset, bool loadingSaveGame) { Network.RemoteInvocation(OtherClientEnteredGame, NetworkTarget.ToOtherClients, channelId, playerId); }
/// <summary> /// Called whenever this entity is unliked from another entity. /// </summary> /// <param name="parent"></param> protected virtual void OnDetachThis(EntityId parent) { }
public void OtherClientEnteredGame(int channelId, EntityId playerId) { Debug.LogAlways("Other client with channelId {0} and playerId {1} entered the game", channelId, playerId); }
/// <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) { }