public GhostTargetWindow(GhostComponent owner) { Title = "Ghost Warp"; _owner = owner; _owner.GhostRequestWarpPoint(); _owner.GhostRequestPlayerNames(); var margin = new MarginContainer() { SizeFlagsVertical = SizeFlags.FillExpand, SizeFlagsHorizontal = SizeFlags.FillExpand, }; _buttonContainer = new VBoxContainer() { SizeFlagsVertical = SizeFlags.FillExpand, SizeFlagsHorizontal = SizeFlags.Fill, SeparationOverride = 5, }; var scrollBarContainer = new ScrollContainer() { SizeFlagsVertical = SizeFlags.FillExpand, SizeFlagsHorizontal = SizeFlags.FillExpand }; margin.AddChild(scrollBarContainer); scrollBarContainer.AddChild(_buttonContainer); Contents.AddChild(margin); }
private void OnActionPerform(EntityUid uid, GhostComponent component, BooActionEvent args) { if (args.Handled) { return; } var ents = _lookup.GetEntitiesInRange(args.Performer, component.BooRadius); var booCounter = 0; foreach (var ent in ents) { var ghostBoo = new GhostBooEvent(); RaiseLocalEvent(ent, ghostBoo, true); if (ghostBoo.Handled) { booCounter++; } if (booCounter >= component.BooMaxTargets) { break; } } args.Handled = true; }
private void OnMindUnvisitedMessage(EntityUid uid, GhostComponent component, MindUnvisitedMessage args) { if (!EntityManager.TryGetEntity(uid, out var entity)) { return; } DeleteEntity(entity); }
private void OnGhostExamine(EntityUid uid, GhostComponent component, ExaminedEvent args) { var timeSinceDeath = _gameTiming.RealTime.Subtract(component.TimeOfDeath); var deathTimeInfo = timeSinceDeath.Minutes > 0 ? Loc.GetString("comp-ghost-examine-time-minutes", ("minutes", timeSinceDeath.Minutes)) : Loc.GetString("comp-ghost-examine-time-seconds", ("seconds", timeSinceDeath.Seconds)); args.PushMarkup(deathTimeInfo); }
void OnHit(Collider target, Vector3 point, Vector3 normal) { Destroy(gameObject); if (!IsServer) { // var vfxTmp = Instantiate(fx, point, Quaternion.LookRotation(normal)); // Destroy(vfxTmp, 5f); //If bullet collides with "Metal" tag if (target.transform.CompareTag("Metal")) { //Instantiate random impact prefab from array Instantiate(metalImpactPrefabs[Random.Range (0, bloodImpactPrefabs.Length)], point, Quaternion.LookRotation(normal)); } } else // 服务端处理 { if (target == null || !target.CompareTag("Player")) // 击中的是环境 { World.GetExistingSystem <BroadcastSystem>().Add(new ProjectileHit { GId = -1, Point = point, Normal = normal }); // Debug.Log($"命中环境."); } else { EntityManager dstManager = World.EntityManager; Entity targetEnt = target.GetComponent <EntityHold>().Ent; GhostComponent ghost = dstManager.GetComponentData <GhostComponent>(targetEnt); HealthComponent health = dstManager.GetComponentData <HealthComponent>(targetEnt); health.Hp -= 10; dstManager.SetComponentData(targetEnt, health); World.EntityManager.World.GetExistingSystem <BroadcastSystem>().Add(new ProjectileHit { GId = ghost.Id, Hp = health.Hp, Point = point, Normal = normal }); // Debug.Log($"命中GHOST: Id={ghost.Id} Hp={health.Hp}"); } } }
void ShowComponent(ref GhostComponent comp) { GUIStyle style = null; if (comp.fields.Length == 0) { style = new GUIStyle(EditorStyles.foldoutHeader); style.fontStyle = FontStyle.Normal; } var prefabType = comp.attribute != null?comp.attribute.PrefabType:GhostPrefabType.All; var ownerPredictedSendType = comp.attribute != null?comp.attribute.OwnerPredictedSendType:GhostSendType.All; comp.isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(comp.isExpanded, System.String.Format("{0}{1} ({2}/{3}/{4})", comp.entityIndex != 0 ? "Child " + (comp.entityIndex - 1).ToString() + ": " : "", comp.name, (prefabType & GhostPrefabType.Server) != 0 ? "S" : "-", (prefabType & GhostPrefabType.InterpolatedClient) != 0 ? "IC" : "-", (prefabType & GhostPrefabType.PredictedClient) != 0 ? "PC" : "-"), style); if (comp.isExpanded) { ++EditorGUI.indentLevel; EditorGUI.BeginDisabledGroup(true); EditorGUILayout.Toggle("Server", (prefabType & GhostPrefabType.Server) != 0); EditorGUILayout.Toggle("Interpolated Client", (prefabType & GhostPrefabType.InterpolatedClient) != 0); EditorGUILayout.Toggle("Predicted Client", (prefabType & GhostPrefabType.PredictedClient) != 0); EditorGUI.EndDisabledGroup(); if (ownerPredictedSendType != GhostSendType.All) { EditorGUILayout.EnumPopup("Send Data To", ownerPredictedSendType); } if ((prefabType & GhostPrefabType.Server) != 0) { EditorGUILayout.Separator(); EditorGUI.BeginDisabledGroup(true); EditorGUILayout.LabelField("Fields"); for (int fi = 0; fi < comp.fields.Length; ++fi) { ShowField(comp.fields[fi]); } EditorGUI.EndDisabledGroup(); } --EditorGUI.indentLevel; } EditorGUILayout.EndFoldoutHeaderGroup(); }
public GhostGui(GhostComponent owner) { IoCManager.InjectDependencies(this); _owner = owner; MouseFilter = MouseFilterMode.Ignore; ReturnToBody.OnPressed += (args) => { owner.SendReturnToBodyMessage(); }; AddChild(ReturnToBody); Update(); }
private void OnGhostStartup(EntityUid uid, GhostComponent component, ComponentStartup args) { // Allow this entity to be seen by other ghosts. var visibility = component.Owner.EnsureComponent <VisibilityComponent>(); visibility.Layer |= (int)VisibilityFlags.Ghost; visibility.Layer &= ~(int)VisibilityFlags.Normal; if (component.Owner.TryGetComponent(out EyeComponent? eye)) { eye.VisibilityMask |= (uint)VisibilityFlags.Ghost; } component.TimeOfDeath = _gameTiming.RealTime; }
public static void InitDefaultOverrides() { GhostDefaultOverrides = new Dictionary <string, GhostComponent>(); AssembliesDefaultOverrides = new HashSet <string>(new [] { "Unity.NetCode", "Unity.Transforms", }); var comp = new GhostComponent { name = "Unity.Transforms.Translation", attribute = new GhostComponentAttribute { PrefabType = GhostPrefabType.All, OwnerPredictedSendType = GhostSendType.All, SendDataForChildEntity = false }, fields = new GhostComponentField[] { new GhostComponentField { name = "Value", attribute = new GhostFieldAttribute { Quantization = 100, Interpolate = true } } }, entityIndex = 0 }; GhostDefaultOverrides.Add(comp.name, comp); comp = new GhostComponent { name = "Unity.Transforms.Rotation", attribute = new GhostComponentAttribute { PrefabType = GhostPrefabType.All, OwnerPredictedSendType = GhostSendType.All, SendDataForChildEntity = false }, fields = new GhostComponentField[] { new GhostComponentField { name = "Value", attribute = new GhostFieldAttribute { Quantization = 1000, Interpolate = true } } }, entityIndex = 0 }; GhostDefaultOverrides.Add(comp.name, comp); }
private void OnGhostStartup(EntityUid uid, GhostComponent component, ComponentStartup args) { // Allow this entity to be seen by other ghosts. var visibility = EntityManager.EnsureComponent <VisibilityComponent>(component.Owner); _visibilitySystem.AddLayer(visibility, (int)VisibilityFlags.Ghost, false); _visibilitySystem.RemoveLayer(visibility, (int)VisibilityFlags.Normal, false); _visibilitySystem.RefreshVisibility(visibility); if (EntityManager.TryGetComponent(component.Owner, out EyeComponent? eye)) { eye.VisibilityMask |= (uint)VisibilityFlags.Ghost; } component.TimeOfDeath = _gameTiming.RealTime; }
private void OnGhostShutdown(EntityUid uid, GhostComponent component, ComponentShutdown args) { // Perf: If the entity is deleting itself, no reason to change these back. if (component.Owner.LifeStage < EntityLifeStage.Terminating) { // Entity can't be seen by ghosts anymore. if (component.Owner.TryGetComponent(out VisibilityComponent? visibility)) { visibility.Layer &= ~(int)VisibilityFlags.Ghost; visibility.Layer |= (int)VisibilityFlags.Normal; } // Entity can't see ghosts anymore. if (component.Owner.TryGetComponent(out EyeComponent? eye)) { eye.VisibilityMask &= ~(uint)VisibilityFlags.Ghost; } } }
private void OnGhostShutdown(EntityUid uid, GhostComponent component, ComponentShutdown args) { // Perf: If the entity is deleting itself, no reason to change these back. if (!Terminating(uid)) { // Entity can't be seen by ghosts anymore. if (EntityManager.TryGetComponent(component.Owner, out VisibilityComponent? visibility)) { _visibilitySystem.RemoveLayer(visibility, (int)VisibilityFlags.Ghost, false); _visibilitySystem.AddLayer(visibility, (int)VisibilityFlags.Normal, false); _visibilitySystem.RefreshVisibility(visibility); } // Entity can't see ghosts anymore. if (EntityManager.TryGetComponent(component.Owner, out EyeComponent? eye)) { eye.VisibilityMask &= ~(uint)VisibilityFlags.Ghost; } } }
public GhostTargetWindow(GhostComponent owner) { MinSize = SetSize = (300, 450); Title = "Ghost Warp"; _owner = owner; _owner.GhostRequestWarpPoint(); _owner.GhostRequestPlayerNames(); _buttonContainer = new VBoxContainer() { VerticalExpand = true, SeparationOverride = 5, }; var scrollBarContainer = new ScrollContainer() { VerticalExpand = true, HorizontalExpand = true }; scrollBarContainer.AddChild(_buttonContainer); Contents.AddChild(scrollBarContainer); }
public GhostGui(GhostComponent owner) { IoCManager.InjectDependencies(this); _owner = owner; var targetMenu = new GhostTargetWindow(owner); MouseFilter = MouseFilterMode.Ignore; _ghostWarp.OnPressed += args => targetMenu.Populate(); _returnToBody.OnPressed += args => owner.SendReturnToBodyMessage(); AddChild(new HBoxContainer { Children = { _returnToBody, _ghostWarp } }); Update(); }
public void Run() { GhostDefinition ghostDefinition = _gameDefinitions.ghostDefinition; if (!_enableEvents.IsEmpty()) { foreach (int i in _ghosts) { GhostComponent ghost = _ghosts.Get1[i]; EcsEntity ghostEntity = _ghosts.Entities[i]; ghostEntity.Set <GhostInFearStateComponent>().EstimateTime = ghostDefinition.FearStateInSec; ghost.Renderer.material.color = ghostDefinition.FearState; } } foreach (int i in _fearStateGhosts) { GhostComponent ghostComponent = _fearStateGhosts.Get1[i]; GhostInFearStateComponent fearState = _fearStateGhosts.Get2[i]; EcsEntity ghostEntity = _fearStateGhosts.Entities[i]; fearState.EstimateTime -= Time.deltaTime; if (fearState.EstimateTime <= 0) { ghostEntity.Unset <GhostInFearStateComponent>(); switch (ghostComponent.GhostType) { case GhostTypes.Blinky: ghostComponent.Renderer.material.color = ghostDefinition.Blinky; break; case GhostTypes.Pinky: ghostComponent.Renderer.material.color = ghostDefinition.Pinky; break; case GhostTypes.Inky: ghostComponent.Renderer.material.color = ghostDefinition.Inky; break; case GhostTypes.Clyde: ghostComponent.Renderer.material.color = ghostDefinition.Clyde; break; default: throw new ArgumentOutOfRangeException(); } return; } Vector2Int currentPosition = ghostEntity.Set <PositionComponent>().Position; foreach (EcsEntity entity in _worldService.WorldField[currentPosition.x][currentPosition.y]) { var player = entity.Get <PlayerComponent>(); if (player == null) { continue; } player.Scores += ghostDefinition.ScoresPerGhost; ghostEntity.Set <DestroyedWorldObjectComponent>(); _ecsWorld.NewEntityWith(out UpdateScoreTableEvent _); } } }
private void OnMindUnvisitedMessage(EntityUid uid, GhostComponent component, MindUnvisitedMessage args) { DeleteEntity(uid); }
public void Run() { GhostConfigComponent ghostConfig = _ghostConfig.Components1[0]; WorldComponent world = _world.Components1[0]; if (_enableEvents.EntitiesCount > 0) { foreach (int i in _ghosts) { GameObject ghost = _ghosts.Components2[i].Transform.gameObject; int ghostEntity = _ghosts.Entities[i]; bool isNew; _ecsWorld .EnsureComponent <GhostInFearStateComponent>(ghostEntity, out isNew) .EstimateTime = ghostConfig.FearStateInSec; if (isNew) { ghost.GetComponent <MeshRenderer>().material.color = ghostConfig.FearState; } } } foreach (int i in _fearStateGhosts) { GhostComponent ghostComponent = _fearStateGhosts.Components1[i]; GhostInFearStateComponent fearState = _fearStateGhosts.Components2[i]; GameObject ghost = _fearStateGhosts.Components3[i].Transform.gameObject; int ghostEntity = _fearStateGhosts.Entities[i]; fearState.EstimateTime -= Time.deltaTime; if (fearState.EstimateTime <= 0) { _ecsWorld.RemoveComponent <GhostInFearStateComponent>(ghostEntity); var material = ghost.GetComponent <MeshRenderer>().material; switch (ghostComponent.GhostType) { case GhostTypes.BLINKY: material.color = ghostConfig.Blinky; break; case GhostTypes.PINKY: material.color = ghostConfig.Pinky; break; case GhostTypes.INKY: material.color = ghostConfig.Inky; break; case GhostTypes.CLYDE: material.color = ghostConfig.Clyde; break; default: throw new ArgumentOutOfRangeException(); } return; } Vector2Int currentPosition = _ecsWorld.GetComponent <PositionComponent>(ghostEntity).Position; foreach (int entity in world.WorldField[currentPosition.x][currentPosition.y]) { var player = _ecsWorld.GetComponent <PlayerComponent>(entity); if (player == null) { continue; } player.Scores += ghostConfig.ScoresPerGhost; _ecsWorld.CreateEntityWith <UpdateScoreTableEvent>(); _ecsWorld.AddComponent <DestroyedWorldObjectComponent>(ghostEntity); } } }
public void Visit(GhostComponent ghost) { ghost.OnPacmanStep(pacman); }
protected override unsafe void OnUpdate() { var preSpawnsAlreadyProcessed = EntityManager.CreateEntityQuery(ComponentType.ReadOnly <PreSpawnsInitialized>()) .CalculateEntityCount(); if (preSpawnsAlreadyProcessed > 0) { // Check if an uninitialized scene has appeared with no ghosts present inside, then just mark it as initialized and continue var prespawns = m_Prespawns.ToEntityArray(Allocator.TempJob); var newScenes = m_UninitializedScenes.ToEntityArray(Allocator.TempJob); for (int j = 0; j < newScenes.Length; ++j) { for (int i = 0; i < prespawns.Length; ++i) { var scenes = EntityManager.GetSharedComponentData <SceneSection>(prespawns[i]); var sceneSystem = World.GetExistingSystem <SceneSystem>(); var sceneEntity = sceneSystem.GetSceneEntity(scenes.SceneGUID); if (sceneEntity == newScenes[j]) { UnityEngine.Debug.LogError("[" + World.Name + "] Prespawned ghosts have already been initialized, this needs to happen for all subscenes at the same time."); return; } } EntityManager.AddComponent <PreSpawnsInitialized>(newScenes[j]); } newScenes.Dispose(); prespawns.Dispose(); return; } // Handle the chunk for an entity type, then handle each entity in the chunk (prespawned entities) var prespawnChunk = m_Prespawns.CreateArchetypeChunkArray(Allocator.TempJob); var entityType = GetEntityTypeHandle(); var preSpawnedIds = GetComponentDataFromEntity <PreSpawnedGhostId>(); var subsceneMap = new NativeMultiHashMap <ulong, Entity>(32, Allocator.Temp); var subscenePadding = new NativeHashMap <ulong, int>(32, Allocator.Temp); var ghostComponents = GetComponentDataFromEntity <GhostComponent>(); // Put all known subscene hashes tracked by the prespawned ghosts into a map for sorting for (int i = 0; i < prespawnChunk.Length; ++i) { var chunk = prespawnChunk[i]; var entities = chunk.GetNativeArray(entityType); for (int j = 0; j < entities.Length; ++j) { var entity = entities[j]; var subsceneHash = EntityManager.GetSharedComponentData <SubSceneGhostComponentHash>(entity).Value; subsceneMap.Add(subsceneHash, entity); } } var subsceneArray = subsceneMap.GetUniqueKeyArray(Allocator.Temp); // Figure out scene id padding or how many IDs were used by the previous scenes in the sorted list, continue // where it left off so each ghost in a scene starts of at the ID+1 of last ghost in the previous scene var scenePadding = 0; for (int i = 0; i < subsceneArray.Item2; ++i) { subscenePadding.Add(subsceneArray.Item1[i], scenePadding); scenePadding += subsceneMap.CountValuesForKey(subsceneArray.Item1[i]); } var PostUpdateCommands = new EntityCommandBuffer(Allocator.Temp); var serverSystems = World.GetExistingSystem <ServerSimulationSystemGroup>(); var ghostTypes = GetComponentDataFromEntity <GhostTypeComponent>(); var ghostPrefabBufferFromEntity = GetBufferFromEntity <GhostPrefabBuffer>(true); var prefabEntity = GetSingletonEntity <GhostPrefabCollectionComponent>(); var ghostReceiveSystem = World.GetExistingSystem <GhostReceiveSystem>(); var ghostSendSystem = World.GetExistingSystem <GhostSendSystem>(); var ghostCollectionSystem = World.GetExistingSystem <GhostCollectionSystem>(); DynamicBuffer <GhostPrefabBuffer> prefabList = ghostPrefabBufferFromEntity[prefabEntity]; int highestPrespawnId = -1; var spawnedGhosts = new NativeList <SpawnedGhostMapping>(1024, Allocator.Temp); for (int i = 0; i < prespawnChunk.Length; ++i) { var chunk = prespawnChunk[i]; var entities = chunk.GetNativeArray(entityType); for (int j = 0; j < entities.Length; ++j) { var entity = entities[j]; var ghostTypeComponent = ghostTypes[entity]; int ghostType; for (ghostType = 0; ghostType < prefabList.Length; ++ghostType) { if (ghostTypes[prefabList[ghostType].Value] == ghostTypeComponent) { break; } } if (ghostType >= prefabList.Length) { UnityEngine.Debug.LogError("Failed to look up ghost type for entity"); return; } // Check if this entity has already been handled if (ghostComponents[entity].ghostId != 0) { UnityEngine.Debug.LogWarning(entity + " already has ghostId=" + ghostComponents[entity].ghostId + " prespawn=" + preSpawnedIds[entity].Value); continue; } // Modfy the entity to its proper version if (EntityManager.HasComponent <GhostPrefabMetaDataComponent>(prefabList[ghostType].Value)) { ref var ghostMetaData = ref EntityManager.GetComponentData <GhostPrefabMetaDataComponent>(prefabList[ghostType].Value).Value.Value; if (serverSystems != null) { for (int rm = 0; rm < ghostMetaData.RemoveOnServer.Length; ++rm) { var rmCompType = ComponentType.ReadWrite(TypeManager.GetTypeIndexFromStableTypeHash(ghostMetaData.RemoveOnServer[rm])); PostUpdateCommands.RemoveComponent(entity, rmCompType); } } else { for (int rm = 0; rm < ghostMetaData.RemoveOnClient.Length; ++rm) { var rmCompType = ComponentType.ReadWrite(TypeManager.GetTypeIndexFromStableTypeHash(ghostMetaData.RemoveOnClient[rm])); PostUpdateCommands.RemoveComponent(entity, rmCompType); } // FIXME: should disable instead of removing once we have a way of doing that without structural changes if (ghostMetaData.DefaultMode == GhostPrefabMetaData.GhostMode.Predicted) { for (int rm = 0; rm < ghostMetaData.DisableOnPredictedClient.Length; ++rm) { var rmCompType = ComponentType.ReadWrite(TypeManager.GetTypeIndexFromStableTypeHash(ghostMetaData.DisableOnPredictedClient[rm])); PostUpdateCommands.RemoveComponent(entity, rmCompType); } } else if (ghostMetaData.DefaultMode == GhostPrefabMetaData.GhostMode.Interpolated) { for (int rm = 0; rm < ghostMetaData.DisableOnInterpolatedClient.Length; ++rm) { var rmCompType = ComponentType.ReadWrite(TypeManager.GetTypeIndexFromStableTypeHash(ghostMetaData.DisableOnInterpolatedClient[rm])); PostUpdateCommands.RemoveComponent(entity, rmCompType); } } } } var subsceneHash = EntityManager.GetSharedComponentData <SubSceneGhostComponentHash>(entity).Value; var newId = preSpawnedIds[entity].Value + subscenePadding[subsceneHash]; if (newId > highestPrespawnId) { highestPrespawnId = newId; } // If on a server we need to allocate the ghost ID for the pre-spawned entity so runtime spawns // will happen from the right start index if (serverSystems != null) { spawnedGhosts.Add(new SpawnedGhostMapping { ghost = new SpawnedGhost { ghostId = newId, spawnTick = 0 }, entity = entity }); var ghostSystemStateComponent = new GhostSystemStateComponent { ghostId = newId, despawnTick = 0, spawnTick = 0 }; PostUpdateCommands.AddComponent(entity, ghostSystemStateComponent); } else if (ghostReceiveSystem != null) { var snapshotSize = ghostCollectionSystem.m_GhostTypeCollection[ghostType].SnapshotSize; spawnedGhosts.Add(new SpawnedGhostMapping { ghost = new SpawnedGhost { ghostId = newId, spawnTick = 0 }, entity = entity }); var newBuffer = PostUpdateCommands.SetBuffer <SnapshotDataBuffer>(entity); newBuffer.ResizeUninitialized(snapshotSize * GhostSystemConstants.SnapshotHistorySize); UnsafeUtility.MemClear(newBuffer.GetUnsafePtr(), snapshotSize * GhostSystemConstants.SnapshotHistorySize); PostUpdateCommands.SetComponent(entity, new SnapshotData { SnapshotSize = snapshotSize, LatestIndex = 0 }); } // Pre-spawned uses spawnTick = 0, if there is a reference to a ghost and it has spawnTick 0 the ref is always resolved // This works because there despawns are high priority and we never create pre-spawned ghosts after connection var ghostComponent = new GhostComponent { ghostId = newId, ghostType = ghostType, spawnTick = 0 }; PostUpdateCommands.SetComponent(entity, ghostComponent); // Mark scene as processed, as whole scene will have been loaded when this entity appeared var sceneSection = EntityManager.GetSharedComponentData <SceneSection>(entity); var sceneSystem = World.GetExistingSystem <SceneSystem>(); var sceneEntity = sceneSystem.GetSceneEntity(sceneSection.SceneGUID); PostUpdateCommands.AddComponent <PreSpawnsInitialized>(sceneEntity); } }
public override void OnInspectorGUI() { m_GhostInfo.snapshotDataPath = EditorGUILayout.TextField("SnapshotData path", m_GhostInfo.snapshotDataPath); m_GhostInfo.spawnSystemPath = EditorGUILayout.TextField("SpawnSystem path", m_GhostInfo.spawnSystemPath); m_GhostInfo.updateSystemPath = EditorGUILayout.TextField("UpdateSystem path", m_GhostInfo.updateSystemPath); m_GhostInfo.serializerPath = EditorGUILayout.TextField("Serializer path", m_GhostInfo.serializerPath); m_GhostInfo.importance = EditorGUILayout.TextField("Importance", m_GhostInfo.importance); m_GhostInfo.transform2d = EditorGUILayout.Toggle("Force 2d transforms", m_GhostInfo.transform2d); for (int i = 0; i < m_GhostInfo.components.Length; ++i) { var title = m_GhostInfo.components[i].name + " ("; if (m_GhostInfo.components[i].server) { title += "S"; } else { title += "-"; } title += "/"; if (m_GhostInfo.components[i].interpolatedClient) { title += "IC"; } else { title += "-"; } title += "/"; if (m_GhostInfo.components[i].predictedClient) { title += "PC"; } else { title += "-"; } title += ")"; m_GhostInfo.components[i].expanded = EditorGUILayout.BeginFoldoutHeaderGroup(m_GhostInfo.components[i].expanded, title); if (m_GhostInfo.components[i].expanded) { m_GhostInfo.components[i].name = EditorGUILayout.TextField("Component name", m_GhostInfo.components[i].name); m_GhostInfo.components[i].server = GUILayout.Toggle(m_GhostInfo.components[i].server, "Server"); m_GhostInfo.components[i].interpolatedClient = GUILayout.Toggle(m_GhostInfo.components[i].interpolatedClient, "Interpolated Client"); m_GhostInfo.components[i].predictedClient = GUILayout.Toggle(m_GhostInfo.components[i].predictedClient, "Predicted Client"); for (int j = 0; j < m_GhostInfo.components[i].fields.Length; ++j) { m_GhostInfo.components[i].fields[j].name = EditorGUILayout.TextField("Field name", m_GhostInfo.components[i].fields[j].name); m_GhostInfo.components[i].fields[j].quantization = EditorGUILayout.IntField("Quantization scale", m_GhostInfo.components[i].fields[j].quantization); m_GhostInfo.components[i].fields[j].interpolate = EditorGUILayout.Toggle("Interpolate", m_GhostInfo.components[i].fields[j].interpolate); } if (GUILayout.Button("Add Field")) { var fields = new GhostField[m_GhostInfo.components[i].fields.Length + 1]; for (int j = 0; j < m_GhostInfo.components[i].fields.Length; ++j) { fields[j] = m_GhostInfo.components[i].fields[j]; } m_GhostInfo.components[i].fields = fields; } } EditorGUILayout.EndFoldoutHeaderGroup(); } if (GUILayout.Button("Add component")) { var comps = new GhostComponent[m_GhostInfo.components.Length + 1]; for (int i = 0; i < m_GhostInfo.components.Length; ++i) { comps[i] = m_GhostInfo.components[i]; } comps[m_GhostInfo.components.Length].fields = new GhostField[0]; comps[m_GhostInfo.components.Length].interpolatedClient = true; comps[m_GhostInfo.components.Length].predictedClient = true; comps[m_GhostInfo.components.Length].server = true; m_GhostInfo.components = comps; } if (GUILayout.Button("Save")) { File.WriteAllText(AssetDatabase.GetAssetPath(assetTarget), JsonUtility.ToJson(m_GhostInfo, true)); } if (GUILayout.Button("Generate code")) { GenerateGhost(); } ApplyRevertGUI(); }
public void OnEntityStorageInsertAttempt(EntityUid uid, GhostComponent comp, InsertIntoEntityStorageAttemptEvent args) { args.Cancel(); }