public static SingularityExplodingBullet CreateSingularityExploadingBullet(SceneMgr mgr, Vector point, Vector position, Player plr) { Vector direction = point - position; direction.Normalize(); SingularityExplodingBullet bullet = new SingularityExplodingBullet(mgr, IdMgr.GetNewId(mgr.GetCurrentPlayer().GetId())); InitSingularityBullet(bullet, mgr, point, position, plr); PointCollisionShape cs = new PointCollisionShape(); cs.Center = bullet.Center; bullet.CollisionShape = cs; ExplodingSingularityBulletControl c = new ExplodingSingularityBulletControl(); c.Speed = SharedDef.BULLET_EXPLOSION_SPEED; c.Strength = SharedDef.BULLET_EXPLOSION_STRENGTH; bullet.AddControl(c); bullet.AddControl(new StickyPointCollisionShapeControl()); return(bullet); }
private void ReceivedSingularityMineHitMsg(NetIncomingMessage msg) { long mineId = msg.ReadInt64(); long id = msg.ReadInt64(); Vector pos = msg.ReadVector(); Vector dir = msg.ReadVector(); float speed = msg.ReadFloat(); foreach (ISceneObject obj in objects) { if (obj.Id == mineId) { DroppingSingularityControl c = obj.GetControlOfType <DroppingSingularityControl>(); if (c == null) { ExplodingSingularityBulletControl c2 = obj.GetControlOfType <ExplodingSingularityBulletControl>(); if (c2 == null) { Logger.Error("Object id " + mineId + " (" + obj.GetType().Name + ") is supposed to be a SingularityMine and have DroppingSingularityControl " + "or SingularityExplodingBullet and have ExplodingSingularityBulletControl, but control is null"); } else { c2.StartDetonation(); } } else { c.StartDetonation(); } continue; } if (obj.Id != id) { continue; } obj.Position = pos; (obj as IMovable).Direction = dir; IMovementControl control = obj.GetControlOfType <IMovementControl>(); if (control != null) { control.Speed = speed; } } //SoundManager.Instance.StartPlayingOnce(SharedDef.MUSIC_EXPLOSION); }
private void ReceivedBulletHitMsg(NetIncomingMessage msg) { long bulletId = msg.ReadInt64(); long aId = msg.ReadInt64(); int damage = msg.ReadInt32(); IProjectile bullet = null; IDestroyable target = null; foreach (ISceneObject obj in objects) { if (obj.Id == bulletId) { if (obj is IProjectile) { bullet = obj as IProjectile; } ExplodingSingularityBulletControl c = obj.GetControlOfType <ExplodingSingularityBulletControl>(); if (c != null) { c.StartDetonation(); } break; } } foreach (ISceneObject obj in objects) { if (obj.Id != aId) { continue; } if (obj is IDestroyable) { target = (obj as IDestroyable); } else { Logger.Error("Object id " + bulletId + " (" + obj.GetType().Name + ") is supposed to be a instance of IDestroyable but it is not"); } break; } if (bullet == null) { return; } if (target != null) { target.TakeDamage(damage, bullet); } else { idsToRemove.Add(aId); } if (!(bullet is SingularityExplodingBullet)) { bullet.DoRemoveMe(); } }
public static void ReadObjectExplodingSingularityBulletControl(this NetIncomingMessage msg, ExplodingSingularityBulletControl c) { msg.ReadControl(c); c.Strength = msg.ReadFloat(); c.Speed = msg.ReadFloat(); }
public static void WriteObjectExplodingSingularityBulletControl(this NetOutgoingMessage msg, ExplodingSingularityBulletControl c) { msg.WriteControl(c); msg.Write(c.Strength); msg.Write(c.Speed); }
public static IList <IControl> ReadControls(this NetIncomingMessage msg) { int controlCount = msg.ReadInt32(); IList <IControl> controls = new List <IControl>(controlCount); for (int i = 0; i < controlCount; ++i) { int hash = msg.ReadInt32(); if (hash == typeof(BaseCollisionControl).GUID.GetHashCode()) { BaseCollisionControl c = new BaseCollisionControl(); msg.ReadControl(c); controls.Add(c); } else if (hash == typeof(BouncingSingularityBulletControl).GUID.GetHashCode()) { BouncingSingularityBulletControl c = new BouncingSingularityBulletControl(); msg.ReadObjectExplodingSingularityBulletControl(c); controls.Add(c); } else if (hash == typeof(DroppingSingularityControl).GUID.GetHashCode()) { DroppingSingularityControl c = new DroppingSingularityControl(); msg.ReadObjectDroppingSingularityControl(c); controls.Add(c); } else if (hash == typeof(AsteroidDroppingSingularityControl).GUID.GetHashCode()) { AsteroidDroppingSingularityControl c = new AsteroidDroppingSingularityControl(); msg.ReadObjectDroppingSingularityControl(c); controls.Add(c); } else if (hash == typeof(NewtonianMovementControl).GUID.GetHashCode()) { NewtonianMovementControl c = new NewtonianMovementControl(); msg.ReadObjectNewtonianMovementControl(c); controls.Add(c); } else if (hash == typeof(LinearMovementControl).GUID.GetHashCode()) { LinearMovementControl c = new LinearMovementControl(); msg.ReadObjectLinearMovementControl(c); controls.Add(c); } else if (hash == typeof(LinearRotationControl).GUID.GetHashCode()) { LinearRotationControl c = new LinearRotationControl(); msg.ReadObjectLinearRotationControl(c); controls.Add(c); } else if (hash == typeof(PowerHookControl).GUID.GetHashCode()) { PowerHookControl c = new PowerHookControl(); msg.ReadObjectHookControl(c); controls.Add(c); } else if (hash == typeof(HookControl).GUID.GetHashCode()) { HookControl c = new HookControl(); msg.ReadObjectHookControl(c); controls.Add(c); } else if (hash == typeof(ExplodingSingularityBulletControl).GUID.GetHashCode()) { ExplodingSingularityBulletControl c = new ExplodingSingularityBulletControl(); msg.ReadObjectExplodingSingularityBulletControl(c); controls.Add(c); } else if (hash == typeof(ExcludingExplodingSingularityBulletControl).GUID.GetHashCode()) { ExcludingExplodingSingularityBulletControl c = new ExcludingExplodingSingularityBulletControl(); msg.ReadObjectExcludingExplodingSingularityBulletControl(c); controls.Add(c); } else if (hash == typeof(MinorAsteroidCollisionReactionControl).GUID.GetHashCode()) { MinorAsteroidCollisionReactionControl c = new MinorAsteroidCollisionReactionControl(); msg.ReadControl(c); controls.Add(c); } else if (hash == typeof(SingularityBulletCollisionReactionControl).GUID.GetHashCode()) { SingularityBulletCollisionReactionControl c = new SingularityBulletCollisionReactionControl(); msg.ReadControl(c); controls.Add(c); } else if (hash == typeof(StatPowerUpCollisionReactionControl).GUID.GetHashCode()) { StatPowerUpCollisionReactionControl c = new StatPowerUpCollisionReactionControl(); msg.ReadControl(c); controls.Add(c); } else if (hash == typeof(StickyPointCollisionShapeControl).GUID.GetHashCode()) { StickyPointCollisionShapeControl c = new StickyPointCollisionShapeControl(); msg.ReadControl(c); controls.Add(c); } else if (hash == typeof(StickySphereCollisionShapeControl).GUID.GetHashCode()) { StickySphereCollisionShapeControl c = new StickySphereCollisionShapeControl(); msg.ReadControl(c); controls.Add(c); } else if (hash == typeof(StickySquareCollisionShapeControl).GUID.GetHashCode()) { StickySquareCollisionShapeControl c = new StickySquareCollisionShapeControl(); msg.ReadControl(c); controls.Add(c); } else if (hash == typeof(BaseHealthControl).GUID.GetHashCode()) { BaseHealthControl c = new BaseHealthControl(); msg.ReadHealthControl(c); controls.Add(c); } else if (hash == typeof(DestroyHpControl).GUID.GetHashCode()) { DestroyHpControl c = new DestroyHpControl(); msg.ReadHealthControl(c); controls.Add(c); } else if (hash == typeof(HpRegenControl).GUID.GetHashCode()) { HpRegenControl c = new HpRegenControl(); msg.ReadHealthRegenControl(c); controls.Add(c); } else if (hash == typeof(ModuleDamageControl).GUID.GetHashCode()) { ModuleDamageControl c = new ModuleDamageControl(); msg.ReadModuleDamageControl(c); controls.Add(c); } else if (hash == typeof(HighlightingControl).GUID.GetHashCode()) { // skip } else { Logger.Error("Received unsupported control (" + hash + ")!"); } } return(controls); }