protected override MyMwcObjectBuilder_Base GetObjectBuilderInternal(bool getExactCopy) { MyMwcObjectBuilder_PrefabKinematic objectBuilder = base.GetObjectBuilderInternal(getExactCopy) as MyMwcObjectBuilder_PrefabKinematic; MyPrefabConfigurationKinematic kinematicConfig = GetConfiguration() as MyPrefabConfigurationKinematic; for (int i = 0; i < kinematicConfig.KinematicParts.Count; i++) { // part is destroyed if (Parts[i] == null) { objectBuilder.KinematicPartsHealth[i] = 0f; objectBuilder.KinematicPartsMaxHealth[i] = null; objectBuilder.KinematicPartsEntityId[i] = null; // Won't transfer } else { objectBuilder.KinematicPartsHealth[i] = Parts[i].Health; objectBuilder.KinematicPartsMaxHealth[i] = Parts[i].GetMaxHealth(); objectBuilder.KinematicPartsEntityId[i] = MyEntityIdentifier.ToNullableInt(Parts[i].EntityId); } } objectBuilder.UseProperties = UseProperties.GetObjectBuilder(); return(objectBuilder); }
void SendCheckpoint(NetConnection sendTo) { Log("SendCheckpoint"); var checkpointEvent = new MyEventCheckpoint(); checkpointEvent.Checkpoint = GetCheckpoint(); Peers.NetworkClient.Send(ref checkpointEvent, sendTo, NetDeliveryMethod.ReliableOrdered, 0, 1024 * 1024); // Send missiles, cannon shots etc. m_entitiesToTransfer.Clear(); MyEntities.FindEntities(AmmoEntitiesPredicate, m_entitiesToTransfer); foreach (var e in m_entitiesToTransfer) { var ammo = (MyAmmoBase)e; var weapon = MyGuiSmallShipHelpers.GetFirstWeaponType(ammo.AmmoType); if (!weapon.HasValue) { continue; } MyEventShoot shootMsg = new MyEventShoot(); shootMsg.Ammo = ammo.AmmoType; shootMsg.Position = new MyMwcPositionAndOrientation(ammo.WorldMatrix); shootMsg.ProjectileEntityId = MyEntityIdentifier.ToNullableInt(ammo.EntityId); shootMsg.ShooterEntityId = (ammo.OwnerEntity != null && ammo.OwnerEntity.EntityId.HasValue) ? ammo.OwnerEntity.EntityId.Value.NumericValue : 0; shootMsg.TargetEntityId = null; shootMsg.Weapon = weapon.Value; Peers.NetworkClient.Send(ref shootMsg, sendTo, NetDeliveryMethod.ReliableOrdered, 0); } }
public void Init(MyPrefabKinematic owner, MyPrefabConfigurationKinematicPart config, float openTime, float closeTime, MyModelsEnum modelEnum, Matrix open, Matrix close, MyMaterialType matType, MySoundCuesEnum?loopSound, MySoundCuesEnum?startSound, MySoundCuesEnum?endSound /*, MyGroupMask grpMask*/, float?health, float?maxHealth, bool activated) { m_needsUpdate = config.NeedsUpdate; m_openTime = openTime * 1000; m_closeTime = closeTime * 1000; m_radialState = MAX_RADIAL_STATE;// 0; m_config = config; m_loopSoundCue = loopSound; m_startSoundCue = startSound; m_endSoundCue = endSound; m_openLocalPosition = open.Translation - close.Translation; m_looping = false; m_ownerKinematic = owner; m_lastUpdateTime = 0; MyMwcObjectBuilder_Base objbuilder = MyMwcObjectBuilder_Base.CreateNewObject(MyMwcObjectBuilderTypeEnum.PrefabKinematicPart, config.PrefabId); objbuilder.EntityId = MyEntityIdentifier.ToNullableInt(EntityId); StringBuilder hudLabelTextSb = null; base.Init(hudLabelTextSb, modelEnum, null, owner, null, objbuilder); if (maxHealth != null) { MaxHealth = maxHealth.Value; } if (health != null) { Health = health.Value; } //LocalMatrix = Matrix.Invert(MyMath.NormalizeMatrix(close)); LocalMatrix = Matrix.CreateTranslation(Vector3.Zero); InitTrianglePhysics(matType, 1.0f, ModelLod0, null, MyConstants.COLLISION_LAYER_PREFAB_KINEMATIC_PART); SetState(KinematicPrefabStateEnum.Sleeping); if (activated) { PersistentFlags &= ~MyPersistentEntityFlags.Deactivated; } else { PersistentFlags |= MyPersistentEntityFlags.Deactivated; } //StartClosing(); }
public void ProjectileHit(MyEntity target, Vector3 position, Vector3 direction, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammoType, MyEntity source) { if (target.EntityId.HasValue) { MyEventProjectileHit msg = new MyEventProjectileHit(); msg.TargetEntityId = target.EntityId.Value.NumericValue; msg.Position = position; msg.Direction = direction; msg.AmmoType = ammoType; msg.SourceEntityId = source != null?MyEntityIdentifier.ToNullableInt(source.EntityId) : null; Peers.SendToAll(ref msg, NetDeliveryMethod.ReliableUnordered); } }
public void DoDamage(MyEntity target, float player, float normal, float emp, MyDamageType damageType, MyAmmoType ammoType, MyEntity source, float newHealthRatio) { if (IsControlledByMe(target)) { MyEventDoDamage msg = new MyEventDoDamage(); msg.TargetEntityId = target.EntityId.Value.NumericValue; msg.PlayerDamage = player; msg.Damage = normal; msg.EmpDamage = emp; msg.DamageType = (byte)damageType; msg.AmmoType = (byte)ammoType; msg.DamageSource = source != null?MyEntityIdentifier.ToNullableInt(source.EntityId) : null; msg.NewHealthRatio = newHealthRatio; Peers.SendToAll(ref msg, NetDeliveryMethod.ReliableUnordered); } }
public void Shoot(MyEntity entity, Matrix shooterMatrix, MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum weapon, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammo, MyEntity target, MyEntityIdentifier?projectileId) { if (!IsControlledByMe(entity)) { return; } MyEventShoot msg = new MyEventShoot(); msg.Position = new MyMwcPositionAndOrientation(shooterMatrix); msg.ShooterEntityId = entity.EntityId.Value.NumericValue; msg.ProjectileEntityId = MyEntityIdentifier.ToNullableInt(projectileId); msg.Ammo = ammo; msg.TargetEntityId = (target != null && target.EntityId.HasValue) ? target.EntityId.Value.NumericValue : (uint?)null; msg.Weapon = weapon; Peers.SendToAll(ref msg, NetDeliveryMethod.ReliableUnordered); }