protected override void ClientWrite(VRage.Library.Collections.BitStream stream,EndpointId forClient, uint timestamp, int maxBitPosition) { base.ClientWrite(stream,forClient,timestamp,maxBitPosition); stream.Write(Entity.WorldMatrix.Translation); MyShipController controller = MySession.Static.ControlledEntity as MyShipController; stream.WriteBool(m_grid != null && controller != null); if (m_grid != null && controller != null) { stream.WriteBool(m_grid.IsStatic); if (m_grid.IsStatic == false) { stream.WriteBool(controller != null); if (controller != null) { stream.WriteInt64(controller.EntityId); Vector2 rotation = controller.RotationIndicator; stream.WriteFloat(rotation.X); stream.WriteFloat(rotation.Y); stream.WriteHalf(controller.RollIndicator); Vector3 position = controller.MoveIndicator; stream.WriteHalf(position.X); stream.WriteHalf(position.Y); stream.WriteHalf(position.Z); Vector3D gridPosition = m_grid.PositionComp.GetPosition(); MyGridPhysicsStateGroup.WriteSubgrids(m_grid, stream, ref forClient, timestamp, maxBitPosition, m_lowPositionOrientation, ref gridPosition, ref m_currentSentPosition); } } } }
public void AddToByteStream(VRage.ByteStream stream) { base.AddToByteStream(stream); stream.addLongList(SpawnOwners); stream.addString(DisplayName); stream.addLongList(BigOwners); }
protected override void ServerRead(VRage.Library.Collections.BitStream stream, ulong clientId,uint timestamp) { base.ServerRead(stream, clientId, timestamp); if (stream.ReadBool()) { if (m_grid != null) { bool isStatic = stream.ReadBool(); if (isStatic == false) { if (stream.ReadBool()) { long entityId = stream.ReadInt64(); Vector2 rotation = new Vector2(); rotation.X = stream.ReadFloat(); rotation.Y = stream.ReadFloat(); float roll = stream.ReadHalf(); Vector3 move = new Vector3(); move.X = stream.ReadHalf(); move.Y = stream.ReadHalf(); move.Z = stream.ReadHalf(); MyShipController controller; if (MyEntities.TryGetEntityById<MyShipController>(entityId, out controller)) { controller.CacheMoveAndRotate(ref move, ref rotation, roll); } } } } } }
// Calculates intersection of line with any triangleVertexes in this model instance. Closest intersection and intersected triangleVertexes will be returned. public override bool GetIntersectionWithLine(ref LineD line, out VRage.Game.Models.MyIntersectionResultLineTriangleEx? t, IntersectionFlags flags = IntersectionFlags.ALL_TRIANGLES) { t = null; return false; //Matrix invWorld = Matrix.Invert(WorldMatrix); //Vector3 from = Vector3.Transform(line.From, invWorld); //Vector3 to = Vector3.Transform(line.To, invWorld); //Line lineLocal = new Line(from, to); //bool res = base.GetIntersectionWithLine(ref line, out t, flags); //if (res) //{ // var definition = MyDefinitionManager.Static.GetCubeBlockDefinition(new MyDefinitionId(MyObjectBuilderTypeEnum.Ladder)); // if (definition.ExcludedAreaForCamera != null) // { // foreach (var b in definition.ExcludedAreaForCamera) // { // if (b.Contains(t.Value.IntersectionPointInObjectSpace) == ContainmentType.Contains) // { // t = null; // return false; // } // } // } //} //return res; }
protected override void ClientWrite(VRage.Library.Collections.BitStream stream) { base.ClientWrite(stream); MyShipController controller = MySession.Static.ControlledEntity as MyShipController; stream.WriteBool(m_grid != null && controller != null); if (m_grid != null && controller != null) { stream.WriteBool(m_grid.IsStatic); if (m_grid.IsStatic == false) { stream.WriteBool(controller != null); if (controller != null) { stream.WriteInt64(controller.EntityId); Vector2 rotation = controller.RotationIndicator; stream.WriteFloat(rotation.X); stream.WriteFloat(rotation.Y); stream.WriteHalf(controller.RollIndicator); Vector3 position = controller.MoveIndicator; stream.WriteHalf(position.X); stream.WriteHalf(position.Y); stream.WriteHalf(position.Z); } } } }
public override void deserialize(VRage.ByteStream stream) { base.deserialize(stream); Settings = new ConquestSettings.SETTINGS(); // Control Points ushort cpCount = stream.getUShort(); Settings.ControlPoints = new List<Records.ControlPoint>(); for (ushort i = 0; i < cpCount; ++i) { Settings.ControlPoints.Add( Records.ControlPoint.deserialize(stream) ); } // CP Period Settings.CPPeriod = (int)stream.getLong(); // Cleanup Period Settings.CleanupPeriod = (int)stream.getLong(); // Block Types ushort blockTypesLength = stream.getUShort(); Settings.BlockTypes = new Records.BlockType[blockTypesLength]; for (ushort i = 0; i < blockTypesLength; ++i) { Settings.BlockTypes[i] = Records.BlockType.deserialize(stream); } // Hull Rules ushort hullRulesLength = stream.getUShort(); Settings.HullRules = new Records.HullRuleSet[hullRulesLength]; for (ushort i = 0; i < hullRulesLength; ++i) { Settings.HullRules[i] = Records.HullRuleSet.deserialize(stream); } }
internal static void Set(VRage.Common.MyRenderVoxelMaterialData[] list) { Array.Resize(ref Materials, list.Length); for(int i=0; i<list.Length; i++) { // copy data :O Materials[i].Near.ColorMetalXZnY_Texture = list[i].ColorMetalXZnY; Materials[i].Near.ColorMetalpY_Texture = list[i].ColorMetalY; Materials[i].Near.NormalGlossXZnY_Texture = list[i].NormalGlossXZnY; Materials[i].Near.NormalGlosspY_Texture = list[i].NormalGlossY; Materials[i].Near.ExtXZnY_Texture = list[i].ExtXZnY; Materials[i].Near.ExtpY_Texture = list[i].ExtY; Materials[i].Near.TextureScale = list[i].Scale; Materials[i].Far1.ColorMetalXZnY_Texture = list[i].ColorMetalXZnYFar1; Materials[i].Far1.ColorMetalpY_Texture = list[i].ColorMetalYFar1; Materials[i].Far1.NormalGlossXZnY_Texture = list[i].NormalGlossXZnYFar1; Materials[i].Far1.NormalGlosspY_Texture = list[i].NormalGlossYFar1; Materials[i].Far1.ExtXZnY_Texture = list[i].ExtXZnYFar1; Materials[i].Far1.ExtpY_Texture = list[i].ExtYFar1; Materials[i].Far1.TextureScale = list[i].ScaleFar1; Materials[i].Far2.ColorMetalXZnY_Texture = list[i].ColorMetalXZnYFar2; Materials[i].Far2.ColorMetalpY_Texture = list[i].ColorMetalYFar2; Materials[i].Far2.NormalGlossXZnY_Texture = list[i].NormalGlossXZnYFar2; Materials[i].Far2.NormalGlosspY_Texture = list[i].NormalGlossYFar2; Materials[i].Far2.ExtXZnY_Texture = list[i].ExtXZnYFar2; Materials[i].Far2.ExtpY_Texture = list[i].ExtYFar2; Materials[i].Far2.TextureScale = list[i].ScaleFar2; } }
public void RemoveFromByteStream(VRage.ByteStream stream) { base.RemoveFromByteStream(stream); SpawnOwners = stream.getLongList(); DisplayName = stream.getString(); BigOwners = stream.getLongList(); }
public override void deserialize(VRage.ByteStream stream) { base.deserialize(stream); NotificationText = stream.getString(); Time = stream.getUShort(); Font = (MyFontEnum)stream.getUShort(); }
public EntityComponent(VRage.ByteStream stream) : base() { long entityId = stream.getLong(); Entity = MyAPIGateway.Entities.GetEntityById(entityId); Log = new Logger("SEGarden.Logic.EntityComponent", (() => EntityId.ToString())); //Log.Trace("Finished EntityComponent deserialize", "ctr"); }
protected override void ClientWrite(VRage.Library.Collections.BitStream stream) { base.ClientWrite(stream); stream.WriteBool(m_character != null); if (m_character != null) { var physGroup = MyExternalReplicable.FindByObject(m_character).FindStateGroup<MyCharacterPhysicsStateGroup>(); long? supportId = null; if (physGroup != null) { physGroup.SetSupport(physGroup.FindSupportDelegate()); supportId = physGroup.GetSupportId(); } stream.WriteBool(supportId.HasValue); if (supportId.HasValue) { stream.WriteInt64(supportId.Value); } Vector3 position = m_character.MoveIndicator; stream.WriteHalf(position.X); stream.WriteHalf(position.Y); stream.WriteHalf(position.Z); Vector2 rotate = m_character.RotationIndicator; stream.WriteFloat(rotate.X); stream.WriteFloat(rotate.Y); stream.WriteFloat(m_character.RollIndicator); // Movement state, 2B stream.WriteUInt16((ushort)m_character.GetNetworkMovementState()); // Movement flag. stream.WriteUInt16((ushort)m_character.PreviousMovementFlags); // Flags, 6 bits bool hasJetpack = m_character.JetpackComp != null; stream.WriteBool(hasJetpack ? m_character.JetpackComp.TurnedOn : false); stream.WriteBool(hasJetpack ? m_character.JetpackComp.DampenersTurnedOn : false); stream.WriteBool(m_character.LightEnabled); // TODO: Remove stream.WriteBool(m_character.ZoomMode == MyZoomModeEnum.IronSight); stream.WriteBool(m_character.RadioBroadcaster.WantsToBeEnabled); // TODO: Remove stream.WriteBool(m_character.TargetFromCamera); stream.WriteFloat(m_character.HeadLocalXAngle); stream.WriteFloat(m_character.HeadLocalYAngle); if ((hasJetpack && m_character.JetpackComp.TurnedOn) == false) { MatrixD matrix = m_character.WorldMatrix; stream.WriteQuaternionNorm(Quaternion.CreateFromForwardUp(matrix.Forward, matrix.Up)); } } }
// Byte Deserialization public ControllableEntity(VRage.ByteStream stream) : base(stream) { Log.ClassName = "GP.Concealment.World.Entities.ControllableEntity"; IsMoving = stream.getBoolean(); RecentlyMoved = stream.getBoolean(); RecentlyMovedEnds = stream.getDateTime(); Log.Trace("New Controllable Entity " + DisplayName, "ctr"); }
public void serialize(VRage.ByteStream stream) { stream.addLong((long)Position.X); stream.addLong((long)Position.Y); stream.addLong((long)Position.Z); stream.addString(Name); stream.addLong(Radius); stream.addLong(TokensPerPeriod); }
// Byte Deserialization public Settings(VRage.ByteStream stream) { ControlledMovingGraceTimeSeconds = (ushort)stream.getUlong(); ControlledMovementGraceDistanceMeters = (ushort)stream.getUlong(); RevealVisibilityMeters = (ushort)stream.getUlong(); //RevealDetectabilityMeters = 10; //50; //RevealCommunicationMeters = 10; //50; //RevealCollisionMeters = 10; //10; ConcealNearAsteroids = stream.getBoolean(); }
public CubeBlockEffect(VRage.Game.MyObjectBuilder_CubeBlockDefinition.CubeBlockEffect Effect) { this.Name = Effect.Name; this.Origin = Effect.Origin; this.Delay = Effect.Delay; this.Loop = Effect.Loop; this.SpawnTimeMin = Effect.SpawnTimeMin; this.SpawnTimeMax = Effect.SpawnTimeMax; this.Duration = Effect.Duration; }
public void AddToByteStream(VRage.ByteStream stream) { stream.addLong(EntityId); stream.addUShort((ushort)Type); stream.addVector3D(Position); stream.addBoolean(Transparent); stream.addBoolean(IsStatic); stream.addUShort((ushort)Revealability); stream.addUShort((ushort)Concealability); stream.addUShort((ushort)Status); }
// Byte Deserialization public ConcealedEntity(VRage.ByteStream stream) : this() { TypeOfEntity = (EntityType)stream.getUShort(); EntityId = stream.getLong(); Position = stream.getVector3D(); // Clients don't need AABB details IsRevealBlocked = stream.getBoolean(); IsObserved = stream.getBoolean(); Log = new Logger("GP.Concealment.World.Entities.ConcealedEntity", EntityId.ToString()); }
internal MyClipmapHandler(uint id, MyClipmapScaleEnum scaleGroup, MatrixD worldMatrix, Vector3I sizeLod0, Vector3D massiveCenter, float massiveRadius, bool spherize, RenderFlags additionalFlags, VRage.Voxels.MyClipmap.PruningFunc prunningFunc) { m_clipmapBase = new MyClipmap(id, scaleGroup, worldMatrix, sizeLod0, this, massiveCenter, massiveRadius, prunningFunc); m_massiveCenter = massiveCenter; m_renderFlags = additionalFlags; if (spherize) m_massiveRadius = massiveRadius; const int mergeLodSubdivideCount = 3; m_mergeHandler = new MyLodMeshMergeHandler(Base, MyCellCoord.MAX_LOD_COUNT, mergeLodSubdivideCount, ref worldMatrix, ref massiveCenter, massiveRadius, m_renderFlags); MyClipmap.AddToUpdate(MyEnvironment.CameraPosition, Base); }
public static BlockType deserialize(VRage.ByteStream stream) { BlockType result = new BlockType(); result.DisplayName = stream.getString(); ushort subTypeStringsCount = stream.getUShort(); result.SubTypeStrings = new List<string>(); for (ushort i = 0; i < subTypeStringsCount; ++i) { result.SubTypeStrings.Add(stream.getString()); } return result; }
// Byte Deserialization public ObservingEntity(VRage.ByteStream stream) : base(stream) { List<long> entitiesViewing = stream.getLongList(); foreach (long id in entitiesViewing) { EntitiesViewing.Add(id, null); } LastObservingTime = stream.getDateTime(); LastObservingPosition = stream.getVector3D(); //Log.Trace("Deserialized LastObservingTime of " + LastObservingTime, "stream ctr"); //Log.Trace("Deserialized LastObservingPosition of " + LastObservingPosition, "stream ctr"); //Log.Trace("Deserialized ViewDistance of " + ViewDistance, "stream ctr"); }
private bool TransferItemsTo(Sandbox.ModAPI.Interfaces.IMyInventory dst, int sourceItemIndex, int? targetItemIndex, VRage.MyFixedPoint? amount,bool useConveyor) { MyInventory dstInventory = dst as MyInventory; if (dstInventory != null) { if (sourceItemIndex < 0 || sourceItemIndex >= this.m_items.Count || (useConveyor == true && IsConnected(dstInventory) == false)) { return false; } Transfer(this as MyInventory, dstInventory, this.GetItems()[sourceItemIndex].ItemId, targetItemIndex.HasValue ? targetItemIndex.Value : -1, amount); return true; } return false; }
internal MyClipmapHandler(uint id, MyClipmapScaleEnum scaleGroup, MatrixD worldMatrix, Vector3I sizeLod0, Vector3D massiveCenter, float massiveRadius, bool spherize, RenderFlags additionalFlags, VRage.Voxels.MyClipmap.PruningFunc prunningFunc) { m_clipmapBase = new MyClipmap(id, scaleGroup, worldMatrix, sizeLod0, this, massiveCenter, massiveRadius, prunningFunc); m_massiveCenter = massiveCenter; m_renderFlags = additionalFlags; m_mergeHandler = null; if (spherize) m_massiveRadius = massiveRadius; if (MyLodMeshMergeHandler.ShouldAllocate(m_mergeHandler)) m_mergeHandler = AllocateMergeHandler(); MyClipmap.AddToUpdate(MyEnvironment.CameraPosition, Base); }
protected override void ServerRead(VRage.Library.Collections.BitStream stream, ulong clientId,uint timestamp) { base.ServerRead(stream, clientId, timestamp); if (m_additionalServerClientData == null) { m_additionalServerClientData = new Dictionary<ulong, Vector3D>(); } m_additionalServerClientData[clientId] = stream.ReadVector3D(); if (stream.ReadBool()) { if (m_grid != null) { bool isStatic = stream.ReadBool(); if (isStatic == false) { if (stream.ReadBool()) { long entityId = stream.ReadInt64(); Vector2 rotation = new Vector2(); rotation.X = stream.ReadFloat(); rotation.Y = stream.ReadFloat(); float roll = stream.ReadHalf(); Vector3 move = new Vector3(); move.X = stream.ReadHalf(); move.Y = stream.ReadHalf(); move.Z = stream.ReadHalf(); Vector3D gridPos = Vector3D.Zero; MyShipController controller; if (MyEntities.TryGetEntityById<MyShipController>(entityId, out controller)) { controller.CacheMoveAndRotate(move, rotation, roll); gridPos = controller.CubeGrid.PositionComp.GetPosition(); } MyGridPhysicsStateGroup.ReadSubGrids(stream, timestamp,true,m_lowPositionOrientation,ref gridPos); } } } } }
// Byte Deserialization public RevealedEntity(VRage.ByteStream stream) : base(stream) { // Nearly everything is available from the ingame Entity IsObserved = stream.getBoolean(); IsRevealBlocked = stream.getBoolean(); List<long> entitiesViewedByList = stream.getLongList(); foreach (long id in entitiesViewedByList) { EntitiesViewedBy.Add(id, null); } RevealedAt = stream.getDateTime(); MovedSinceIsInAsteroidCheck = true; Log.ClassName = "GP.Concealment.World.Entities.RevealedEntity"; Log.Trace("Finished RevealedEntity deserialize constructor", "ctr"); }
public static ControlPoint deserialize(VRage.ByteStream stream) { ControlPoint result = new ControlPoint(); long x, y, z; x = stream.getLong(); y = stream.getLong(); z = stream.getLong(); result.Position = new VRageMath.Vector3D(x, y, z); result.Name = stream.getString(); result.Radius = (int)stream.getLong(); result.TokensPerPeriod = (int)stream.getLong(); return result; }
public static HullRuleSet deserialize(VRage.ByteStream stream) { HullRuleSet result = new HullRuleSet(); result.DisplayName = stream.getString(); result.MaxPerFaction = stream.getUShort(); result.MaxPerSoloPlayer = stream.getUShort(); result.CaptureMultiplier = stream.getUShort(); result.MaxBlocks = (int)stream.getLong(); result.ShouldBeStation = stream.getBoolean(); ushort blockTypeLimitsCount = stream.getUShort(); result.BlockTypeLimits = new int[blockTypeLimitsCount]; for (ushort i = 0; i < blockTypeLimitsCount; ++i) { result.BlockTypeLimits[i] = stream.getUShort(); } return result; }
/// <summary> /// Gets the first available non-empty cargo container on a grid. /// If optional parameters given, first cargo which can fit that volume. /// </summary> /// <param name="def">Optional: Builder definition</param> /// <param name="count">Optional: Number of items</param> /// <returns></returns> public static InGame.IMyCargoContainer getAvailableCargo(this IMyCubeGrid grid, VRage.ObjectBuilders.SerializableDefinitionId? def = null, int count = 1) { List<IMySlimBlock> containers = new List<IMySlimBlock>(); grid.GetBlocks(containers, x => x.FatBlock != null && x.FatBlock is InGame.IMyCargoContainer); if (containers.Count == 0) return null; if (def == null) { // Don't care about fit, just return the first one return containers[0].FatBlock as InGame.IMyCargoContainer; } else { foreach (IMySlimBlock block in containers) { InGame.IMyCargoContainer c = block.FatBlock as InGame.IMyCargoContainer; Interfaces.IMyInventoryOwner invo = c as Interfaces.IMyInventoryOwner; Interfaces.IMyInventory inv = invo.GetInventory(0); // TODO: check for fit return c; } } return null; }
void VRage.Game.ModAPI.IMyInventory.RemoveItems(uint itemId, VRage.MyFixedPoint? amount, bool sendEvent, bool spawn) { RemoveItems(itemId, amount, sendEvent, spawn); }
void PositionComp_OnPositionChanged(VRage.Game.Components.MyPositionComponentBase obj) { if (m_entity != null) Coords = m_entity.PositionComp.GetPosition(); }
bool IMyInventory.TransferItemTo(IMyInventory dst, int sourceItemIndex, int? targetItemIndex, bool? stackIfPossible, VRage.MyFixedPoint? amount) { return TransferItemsTo(dst, sourceItemIndex, targetItemIndex, amount,true); }