/*
 * Copyright (C) 2019 Open Source Robotics Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
*/

syntax = "proto3";

package gz.msgs;
option java_package = "com.gz.msgs";

import "gz/msgs/header.proto";
import "gz/msgs/world_stats.proto";

/// \brief Holds all the information needed to reconstruct a component.
message SerializedComponent
{
  /// \brief Unique ID that represents a component's type.
  uint64 type = 1;

  /// \brief Component's serialized data.
  bytes component = 2;

  /// \brief Whether the component should be removed at the current state.
  bool remove = 3;
};

/// \brief Holds all the information needed to reconstruct an entity and its
/// components.
message SerializedEntity
{
  /// \brief The entity is uniquely identified by its ID.
  uint64 id = 1;

  /// \brief All the components belonging to the entity.
  repeated SerializedComponent components = 2;

  /// \brief Whether the entity and all its components should be removed at the
  /// current state.
  bool remove = 3;
};

/// \brief Holds all the information needed to reconstruct the state of an
/// entity-component-system (ECS) architecture at a given time.
/// An ECS's state consists of several entities, each with an arbitrary number
/// of components tied to them.
message SerializedState
{
  /// \brief Header data, which contains the simulation time.
  gz.msgs.Header header = 1;

  /// \brief All the entities currently in the simulation.
  repeated SerializedEntity entities = 2;
};

/// \brief All the data needed to step an ECS system, such as current
/// simulation time and entity states.
message SerializedStep
{
  /// \brief Iteration information, such as sim time and paused state.
  WorldStatistics stats = 1;

  /// \brief State of entities and components.
  SerializedState state = 2;
};
